diff --git a/unit_tests/test_actions.py b/unit_tests/test_actions.py index e542ea34..1075eb56 100644 --- a/unit_tests/test_actions.py +++ b/unit_tests/test_actions.py @@ -19,6 +19,8 @@ from unit_tests.test_utils import ( get_default_config, ) +import charmhelpers.core.unitdata + __default_config = get_default_config() # NOTE(freyes): the default 'distro' makes the test suite behave different # depending on where it's being executed @@ -34,6 +36,12 @@ TO_PATCH = [ class PauseTestCase(CharmTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + charmhelpers.core.unitdata._KV = ( + charmhelpers.core.unitdata.Storage(':memory:')) + def setUp(self): super(PauseTestCase, self).setUp( actions, @@ -50,6 +58,12 @@ class PauseTestCase(CharmTestCase): class ResumeTestCase(CharmTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + charmhelpers.core.unitdata._KV = ( + charmhelpers.core.unitdata.Storage(':memory:')) + def setUp(self): super(ResumeTestCase, self).setUp( actions, [ @@ -65,6 +79,12 @@ class ResumeTestCase(CharmTestCase): class ClearUnitKnownhostCacheTestCase(CharmTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + charmhelpers.core.unitdata._KV = ( + charmhelpers.core.unitdata.Storage(':memory:')) + @staticmethod def _relation_get(attribute=None, unit=None, rid=None): return { @@ -153,6 +173,12 @@ class ClearUnitKnownhostCacheTestCase(CharmTestCase): class SyncComputeAvailabilityZonesTestCase(CharmTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + charmhelpers.core.unitdata._KV = ( + charmhelpers.core.unitdata.Storage(':memory:')) + @staticmethod def _relation_get(attribute=None, unit=None, rid=None): return { @@ -286,6 +312,12 @@ class SyncComputeAvailabilityZonesTestCase(CharmTestCase): class MainTestCase(CharmTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + charmhelpers.core.unitdata._KV = ( + charmhelpers.core.unitdata.Storage(':memory:')) + def setUp(self): super(MainTestCase, self).setUp( actions, diff --git a/unit_tests/test_actions_openstack_upgrade.py b/unit_tests/test_actions_openstack_upgrade.py index 3092e8d2..5a10a86f 100644 --- a/unit_tests/test_actions_openstack_upgrade.py +++ b/unit_tests/test_actions_openstack_upgrade.py @@ -15,6 +15,8 @@ from mock import patch from unit_tests.test_utils import CharmTestCase +import charmhelpers.core.unitdata + import actions.openstack_upgrade as openstack_upgrade @@ -29,6 +31,12 @@ TO_PATCH = [ class TestNovaCCUpgradeActions(CharmTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + charmhelpers.core.unitdata._KV = ( + charmhelpers.core.unitdata.Storage(':memory:')) + def setUp(self): super(TestNovaCCUpgradeActions, self).setUp(openstack_upgrade, TO_PATCH) diff --git a/unit_tests/test_nova_cc_contexts.py b/unit_tests/test_nova_cc_contexts.py index 777fd06e..b0085933 100644 --- a/unit_tests/test_nova_cc_contexts.py +++ b/unit_tests/test_nova_cc_contexts.py @@ -19,6 +19,8 @@ import hooks.nova_cc_context as context from charmhelpers.contrib.openstack import neutron from charmhelpers.contrib.openstack import utils +import charmhelpers.core.unitdata + from unit_tests.test_utils import CharmTestCase TO_PATCH = [ @@ -41,6 +43,13 @@ def fake_log(msg, level=None): class NovaComputeContextTests(CharmTestCase): + + @classmethod + def setUpClass(cls): + super().setUpClass() + charmhelpers.core.unitdata._KV = ( + charmhelpers.core.unitdata.Storage(':memory:')) + def setUp(self): super(NovaComputeContextTests, self).setUp(context, TO_PATCH) self.relation_get.side_effect = self.test_relation.get diff --git a/unit_tests/test_nova_cc_hooks.py b/unit_tests/test_nova_cc_hooks.py index a02f493f..2f384c8b 100644 --- a/unit_tests/test_nova_cc_hooks.py +++ b/unit_tests/test_nova_cc_hooks.py @@ -19,6 +19,7 @@ import tempfile from unit_tests.test_utils import CharmTestCase import charmhelpers.contrib.hardening.harden as harden +import charmhelpers.core.unitdata import hooks.nova_cc_utils as utils import hooks.nova_cc_hooks as hooks @@ -96,6 +97,12 @@ FAKE_KS_AUTH_CFG = { class NovaCCHooksTests(CharmTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + charmhelpers.core.unitdata._KV = ( + charmhelpers.core.unitdata.Storage(':memory:')) + def setUp(self): super(NovaCCHooksTests, self).setUp(hooks, TO_PATCH) (tmpfd, hooks.NOVA_CONSOLEAUTH_OVERRIDE) = tempfile.mkstemp() diff --git a/unit_tests/test_nova_cc_utils.py b/unit_tests/test_nova_cc_utils.py index e09085c1..abc106e7 100644 --- a/unit_tests/test_nova_cc_utils.py +++ b/unit_tests/test_nova_cc_utils.py @@ -16,6 +16,8 @@ from collections import OrderedDict from mock import patch, MagicMock, call import subprocess +import charmhelpers.core.unitdata + from unit_tests.test_utils import ( CharmTestCase, patch_open, @@ -247,6 +249,12 @@ NM_CELLS_LIST = b""" class NovaCCUtilsTests(CharmTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + charmhelpers.core.unitdata._KV = ( + charmhelpers.core.unitdata.Storage(':memory:')) + def setUp(self): super(NovaCCUtilsTests, self).setUp(utils, TO_PATCH) self.config.side_effect = self.test_config.get