diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index ed0779fb..e9479e96 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -13,8 +13,21 @@ # limitations under the License. import sys +from unittest import mock sys.path.append('actions') sys.path.append('hooks') sys.path.append('lib') sys.path.append('unit_tests') + +# 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_ceph_radosgw_context.py b/unit_tests/test_ceph_radosgw_context.py index b259a7f6..b426c2ae 100644 --- a/unit_tests/test_ceph_radosgw_context.py +++ b/unit_tests/test_ceph_radosgw_context.py @@ -47,6 +47,7 @@ class HAProxyContextTests(CharmTestCase): self.arch.return_value = 'amd64' @patch('ceph_radosgw_context.https') + @patch('charmhelpers.contrib.openstack.context.is_ipv6_disabled') @patch('charmhelpers.contrib.openstack.context.get_relation_ip') @patch('charmhelpers.contrib.openstack.context.mkdir') @patch('charmhelpers.contrib.openstack.context.local_unit') @@ -56,7 +57,7 @@ class HAProxyContextTests(CharmTestCase): @patch('charmhelpers.contrib.hahelpers.cluster.relation_ids') def test_ctxt(self, _harelation_ids, _ctxtrelation_ids, _haconfig, _ctxtconfig, _local_unit, _mkdir, _get_relation_ip, - _mock_https): + _is_ipv6_disabled, _mock_https): _mock_https.return_value = False _get_relation_ip.return_value = '10.0.0.10' _ctxtconfig.side_effect = self.test_config.get @@ -74,6 +75,7 @@ class HAProxyContextTests(CharmTestCase): 'https': False } self.assertEqual(expect, haproxy_context()) + _is_ipv6_disabled.assert_called_once_with() class MonContextTest(CharmTestCase):