From 456a418ba4daf1feb6a7425e254774d7301ef3fc Mon Sep 17 00:00:00 2001 From: Jadon Naas Date: Tue, 21 May 2024 11:13:39 -0400 Subject: [PATCH] Fix mocking for wrapped OpenStack releases A recent change in charms.openstack to support wrapped OpenStack releases caused unit tests to fail. The unit tests failed because mocking was incompatible with the change. This commit mocks the default_get_charm instance where the charms.openstack change was breaking unit tests. Closes-Bug: 2066281 Change-Id: I87263ac24e5e4061757e5fb8bb167a43b2e85f93 --- unit_tests/test_lib_charm_openstack_designate_bind.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unit_tests/test_lib_charm_openstack_designate_bind.py b/unit_tests/test_lib_charm_openstack_designate_bind.py index 0f10973..c5f87f6 100644 --- a/unit_tests/test_lib_charm_openstack_designate_bind.py +++ b/unit_tests/test_lib_charm_openstack_designate_bind.py @@ -49,6 +49,9 @@ class Helper(test_utils.PatchHelper): # simply the CompareHostReleases to just return then string for # comparisons. (won't work for xenial/bionic) self.ch_core_host.CompareHostReleases.side_effect = lambda x: x + charm = designate_bind.DesignateBindCharm(release='icehouse') + self.patch("charms_openstack.charm.core.default_get_charm_instance", + new=lambda *_, **__: charm) self.patch('charms_openstack.charm.core._singleton', new=None) @@ -81,6 +84,9 @@ class TestOpenStackDesignateBind(Helper): self.ch_core_host.lsb_release.return_value = { "DISTRIB_CODENAME": "focal" } + actual_charm = designate_bind.DesignateBindCharm(release='icehouse') + self.patch("charms_openstack.charm.core.default_get_charm_instance", + new=lambda *_, **__: actual_charm) charm = designate_bind.DesignateBindCharm.singleton self.assertEqual(charm.services, ["named"]) for v in charm.restart_map.values():