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
This commit is contained in:
parent
655f36440f
commit
456a418ba4
@ -49,6 +49,9 @@ class Helper(test_utils.PatchHelper):
|
|||||||
# simply the CompareHostReleases to just return then string for
|
# simply the CompareHostReleases to just return then string for
|
||||||
# comparisons. (won't work for xenial/bionic)
|
# comparisons. (won't work for xenial/bionic)
|
||||||
self.ch_core_host.CompareHostReleases.side_effect = lambda x: x
|
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)
|
self.patch('charms_openstack.charm.core._singleton', new=None)
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +84,9 @@ class TestOpenStackDesignateBind(Helper):
|
|||||||
self.ch_core_host.lsb_release.return_value = {
|
self.ch_core_host.lsb_release.return_value = {
|
||||||
"DISTRIB_CODENAME": "focal"
|
"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
|
charm = designate_bind.DesignateBindCharm.singleton
|
||||||
self.assertEqual(charm.services, ["named"])
|
self.assertEqual(charm.services, ["named"])
|
||||||
for v in charm.restart_map.values():
|
for v in charm.restart_map.values():
|
||||||
|
Loading…
Reference in New Issue
Block a user