]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Do not alter test_config global in test_extension_ext_gw_mode
authorSalvatore Orlando <salv.orlando@gmail.com>
Tue, 9 Jul 2013 23:32:51 +0000 (01:32 +0200)
committerSalvatore Orlando <salv.orlando@gmail.com>
Tue, 6 Aug 2013 15:14:33 +0000 (08:14 -0700)
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
neutron/tests/unit/test_db_plugin.py
neutron/tests/unit/test_extension_ext_gw_mode.py

index bea46b64b5d4b07b6d2e6db53f60a0c65b9cb18b..80c4575dbac7ccb5d55dd6b674cc9b1a10311348 100644 (file)
@@ -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
 
 
index 3c28a7a0bdcd620cf55239c520529d71b9bedb28..f01a1d0167c3ea5e5ca6a14b3076444321601a5c 100644 (file)
@@ -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)
 
index 65e11314a2e01b101319da5d020c2065cfb9949e..8732debbc4aceaf081cd3265714bf24c53507d18 100644 (file)
@@ -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):