mocks: Preserve CompareOpenStackReleases
Global mocking causes this to become a MagicMock, however we need to preserve this to ensure that sorting of the releases in tests continues to work properly. Drive-by fix for Python 3.12 compatibility in assert usage. Change-Id: I07aa60c270c5966018931c25ffe66cd3c89a77a3
This commit is contained in:
parent
355d65f64c
commit
b903273d28
@ -5,6 +5,8 @@ charmhelpers = None
|
||||
|
||||
|
||||
def mock_charmhelpers():
|
||||
# Preseve CompareOpenStackReleases for later
|
||||
from charmhelpers.contrib.openstack.utils import CompareOpenStackReleases
|
||||
# Mock out charmhelpers so that we can test without it.
|
||||
# also stops sideeffects from occuring.
|
||||
global charmhelpers
|
||||
@ -55,6 +57,8 @@ def mock_charmhelpers():
|
||||
charmhelpers.core.hookenv.charm_dir)
|
||||
charmhelpers.core.hookenv.charm_dir.return_value = "/tmp"
|
||||
|
||||
# restore comparator so sorting releases actually works
|
||||
charmhelpers.contrib.openstack.utils.CompareOpenStackReleases = CompareOpenStackReleases # noqa
|
||||
# mock in the openstack releases so that the tests can run
|
||||
charmhelpers.contrib.openstack.utils.OPENSTACK_RELEASES = (
|
||||
'diablo',
|
||||
|
@ -1154,7 +1154,7 @@ class TestHAOpenStackCharm(BaseOpenStackCharmTest):
|
||||
self.target.configure_tls()
|
||||
self.configure_cert.assert_has_calls(cert_calls)
|
||||
self.configure_ca.assert_has_calls(ca_calls)
|
||||
self.configure_apache.called_once_with()
|
||||
self.configure_apache.assert_called_once_with()
|
||||
self.set_state.assert_has_calls(set_state_calls)
|
||||
self.create_ip_cert_links.assert_called_once_with(
|
||||
'/etc/apache2/ssl/charmname')
|
||||
|
@ -142,7 +142,7 @@ class TestOpenStackCephConsumingCharm(BaseOpenStackCharmTest):
|
||||
self.CephBlueStoreCompressionContext.return_value = (
|
||||
bluestore_compression)
|
||||
bluestore_compression.validate.side_effect = KeyError
|
||||
self.assertEquals(self.target._get_bluestore_compression(), None)
|
||||
self.assertEqual(self.target._get_bluestore_compression(), None)
|
||||
bluestore_compression.validate.side_effect = None
|
||||
self.assertDictEqual(
|
||||
self.target._get_bluestore_compression(),
|
||||
|
Loading…
Reference in New Issue
Block a user