New policy code requires that CONF is already initialized when policy
checks are invoked. It means that no Neutron context objects should be
created before BaseTestCase.setUp() is called that will set
configuration, among other things.
Ideally, we would just make sure that all test cases invoke
super().setUp() as the very first line of any subclass setUp() methods.
But since some of test cases require prior setup (like mocking extension
manager) before proceeding to base class, we end up with magically
shuffling context instantiations to occur below super() calls.
Change-Id: Ib1039ea1ff9480ca57f9cb0c917469d0d2ad28b8
Closes-Bug: #
1400301
LOG.info(_("rbridge id %s"), self._switch['rbridge_id'])
self._driver = mock.MagicMock()
- self.context = oslo_context.get_admin_context()
- self.context.session = db.get_session()
self.l3_plugin = importutils.import_object(L3_SVC_PLUGIN)
with mock.patch.object(self.l3_plugin,
'brocade_init', new=mocked_brocade_init):
super(BrocadeSVIPlugin_TestCases, self).setUp()
+ self.context = oslo_context.get_admin_context()
+ self.context.session = db.get_session()
class TestBrocadeSVINatBase(test_l3_plugin.L3NatExtensionTestCase,
fmt = 'json'
def setUp(self):
- self.adminContext = context.get_admin_context()
plugin = 'neutron.tests.unit.test_agent_ext_plugin.TestAgentPlugin'
# for these tests we need to enable overlapping ips
cfg.CONF.set_default('allow_overlapping_ips', True)
ext_mgr = AgentTestExtensionManager()
self.addCleanup(self.restore_resource_attribute_map)
super(AgentDBTestCase, self).setUp(plugin=plugin, ext_mgr=ext_mgr)
+ self.adminContext = context.get_admin_context()
def restore_resource_attribute_map(self):
# Restore the originak RESOURCE_ATTRIBUTE_MAP
fmt = 'json'
def setUp(self):
- self.adminContext = context.get_admin_context()
test_lib.test_config['config_files'] = [
vmware.get_fake_conf('nsx.ini.full.test')]
cfg.CONF.set_override('api_extensions_path', vmware.NSXEXT_PATH)
self.addCleanup(self.restore_resource_attribute_map)
super(MacLearningDBTestCase, self).setUp(plugin=vmware.PLUGIN_NAME,
ext_mgr=ext_mgr)
+ self.adminContext = context.get_admin_context()
def restore_resource_attribute_map(self):
# Restore the original RESOURCE_ATTRIBUTE_MAP