diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index 82861fe1..74c76acb 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -32,3 +32,15 @@ def _add_path(path): _add_path(_root) + +# Patch out lsb_release() and get_platform() as unit tests should be fully +# insulated from the underlying platform. Unit tests assume that the system is +# ubuntu jammy. +mock.patch( + 'charmhelpers.osplatform.get_platform', return_value='ubuntu' +).start() +mock.patch( + 'charmhelpers.core.host.lsb_release', + return_value={ + 'DISTRIB_CODENAME': 'jammy', + }).start() diff --git a/unit_tests/test_nova_cc_contexts.py b/unit_tests/test_nova_cc_contexts.py index 3e64b8d0..e6d03fe2 100644 --- a/unit_tests/test_nova_cc_contexts.py +++ b/unit_tests/test_nova_cc_contexts.py @@ -141,6 +141,7 @@ class NovaComputeContextTests(CharmTestCase): self.assertEqual(ctxt['nova_url'], 'http://10.0.1.1:8774/v2') self.assertFalse('neutron_url' in ctxt) + @mock.patch('charmhelpers.contrib.openstack.context.is_ipv6_disabled') @mock.patch('charmhelpers.core.hookenv.relation_ids') @mock.patch('charmhelpers.contrib.openstack.context.config') @mock.patch('charmhelpers.contrib.openstack.context.get_relation_ip') @@ -159,12 +160,14 @@ class NovaComputeContextTests(CharmTestCase): mock_local_unit, mock_get_netmask_for_address, mock_get_address_in_network, mock_kv, mock_https, mock_network_manager, mock_mkdir, - mock_get_relation_ip, mock_config, mock_rids): + mock_get_relation_ip, mock_config, mock_rids, + mock_is_ipv6_disabled): self.os_release.return_value = 'ocata' mock_config.side_effect = self.test_config.get mock_https.return_value = False mock_network_manager.return_value = 'neutron' mock_rids.return_value = [] + mock_is_ipv6_disabled.return_value = True ctxt = context.HAProxyContext()() self.assertEqual(ctxt['service_ports']['nova-api-os-compute'], [8774, 8764])