From 05691c2e4c69e389ec52f8083f0b1d17590aa02b Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 10 Jul 2013 01:32:51 +0200 Subject: [PATCH] Do not alter test_config global in test_extension_ext_gw_mode Bug 1199557 Instead, allow subclasses to instruct the base test class which API extension manager they should use as it is already done with the plugin name. Change-Id: If4e53ffca3bdeb4fb218918358437aca41489de4 --- neutron/tests/unit/nicira/test_nicira_plugin.py | 6 +++--- neutron/tests/unit/test_db_plugin.py | 6 +++--- neutron/tests/unit/test_extension_ext_gw_mode.py | 9 ++++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/neutron/tests/unit/nicira/test_nicira_plugin.py b/neutron/tests/unit/nicira/test_nicira_plugin.py index bea46b64b..80c4575db 100644 --- a/neutron/tests/unit/nicira/test_nicira_plugin.py +++ b/neutron/tests/unit/nicira/test_nicira_plugin.py @@ -90,7 +90,7 @@ class NiciraPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase): # Emulate tests against NVP 2.x instance.return_value.get_nvp_version.return_value = NVPVersion("2.9") instance.return_value.request.side_effect = _fake_request - super(NiciraPluginV2TestCase, self).setUp(PLUGIN_NAME) + super(NiciraPluginV2TestCase, self).setUp(plugin=PLUGIN_NAME) cfg.CONF.set_override('metadata_mode', None, 'NVP') self.addCleanup(self.fc.reset_all) self.addCleanup(self.mock_nvpapi.stop) @@ -861,8 +861,8 @@ class TestNiciraQoSQueue(NiciraPluginV2TestCase): self.assertEqual(queue['qos_queue']['max'], 20) -class NiciraExtGwModeTestCase(test_ext_gw_mode.ExtGwModeTestCase, - NiciraPluginV2TestCase): +class NiciraExtGwModeTestCase(NiciraPluginV2TestCase, + test_ext_gw_mode.ExtGwModeTestCase): pass diff --git a/neutron/tests/unit/test_db_plugin.py b/neutron/tests/unit/test_db_plugin.py index 3c28a7a0b..f01a1d016 100644 --- a/neutron/tests/unit/test_db_plugin.py +++ b/neutron/tests/unit/test_db_plugin.py @@ -76,7 +76,8 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): fmt = 'json' resource_prefix_map = {} - def setUp(self, plugin=None, service_plugins=None): + def setUp(self, plugin=None, service_plugins=None, + ext_mgr=None): super(NeutronDbPluginV2TestCase, self).setUp() # Make sure at each test a new instance of the plugin is returned @@ -148,8 +149,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): native_sorting_attr_name, False)) self._skip_native_sorting = not _is_native_sorting_support() - - ext_mgr = test_config.get('extension_manager', None) + ext_mgr = ext_mgr or test_config.get('extension_manager') if ext_mgr: self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr) diff --git a/neutron/tests/unit/test_extension_ext_gw_mode.py b/neutron/tests/unit/test_extension_ext_gw_mode.py index 65e11314a..8732debbc 100644 --- a/neutron/tests/unit/test_extension_ext_gw_mode.py +++ b/neutron/tests/unit/test_extension_ext_gw_mode.py @@ -26,7 +26,6 @@ from oslo.config import cfg from webob import exc from neutron.common import constants -from neutron.common.test_lib import test_config from neutron.db import api as db_api from neutron.db import l3_db from neutron.db import l3_gwmode_db @@ -301,18 +300,18 @@ class TestL3GwModeMixin(base.BaseTestCase): class ExtGwModeTestCase(test_db_plugin.NeutronDbPluginV2TestCase, test_l3_plugin.L3NatTestCaseMixin): - def setUp(self): + def setUp(self, plugin=None): # Store l3 resource attribute map as it will be updated self._l3_attribute_map_bk = {} for item in l3.RESOURCE_ATTRIBUTE_MAP: self._l3_attribute_map_bk[item] = ( l3.RESOURCE_ATTRIBUTE_MAP[item].copy()) - test_config['plugin_name_v2'] = ( + plugin = plugin or ( 'neutron.tests.unit.test_extension_ext_gw_mode.TestDbPlugin') - test_config['extension_manager'] = TestExtensionManager() # for these tests we need to enable overlapping ips cfg.CONF.set_default('allow_overlapping_ips', True) - super(ExtGwModeTestCase, self).setUp() + super(ExtGwModeTestCase, self).setUp(plugin=plugin, + ext_mgr=TestExtensionManager()) self.addCleanup(self.restore_l3_attribute_map) def restore_l3_attribute_map(self): -- 2.45.2