def setUp(self): self.adminContext = context.get_admin_context() test_config['config_files'] = [get_fake_conf('nvp.ini.full.test')] test_config['plugin_name_v2'] = PLUGIN_NAME cfg.CONF.set_override('api_extensions_path', NVPEXT_PATH) # Save the original RESOURCE_ATTRIBUTE_MAP self.saved_attr_map = {} for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems(): self.saved_attr_map[resource] = attrs.copy() ext_mgr = MacLearningExtensionManager() test_config['extension_manager'] = ext_mgr # mock nvp api client self.fc = fake_nvpapiclient.FakeClient(STUBS_PATH) self.mock_nvpapi = mock.patch(NVPAPI_NAME, autospec=True) instance = self.mock_nvpapi.start() def _fake_request(*args, **kwargs): return self.fc.fake_request(*args, **kwargs) # Emulate tests against NVP 2.x instance.return_value.get_nvp_version.return_value = NVPVersion("3.0") instance.return_value.request.side_effect = _fake_request cfg.CONF.set_override('metadata_mode', None, 'NVP') self.addCleanup(self.fc.reset_all) self.addCleanup(self.mock_nvpapi.stop) self.addCleanup(self.restore_resource_attribute_map) self.addCleanup(cfg.CONF.reset) super(MacLearningDBTestCase, self).setUp()
def setUp(self): # mock nvp api client self.fc = fake_nvpapiclient.FakeClient(STUBS_PATH) mock_nvpapi = mock.patch(NVPAPI_NAME, autospec=True) # Avoid runs of the synchronizer looping call # These unit tests will excplicitly invoke synchronization patch_sync = mock.patch.object(sync, '_start_loopingcall') self.mock_nvpapi = mock_nvpapi.start() patch_sync.start() self.mock_nvpapi.return_value.login.return_value = "the_cookie" # Emulate tests against NVP 3.x self.mock_nvpapi.return_value.get_nvp_version.return_value = ( NvpApiClient.NVPVersion("3.1")) def _fake_request(*args, **kwargs): return self.fc.fake_request(*args, **kwargs) self.mock_nvpapi.return_value.request.side_effect = _fake_request self.fake_cluster = nsx_cluster.NSXCluster( name='fake-cluster', nsx_controllers=['1.1.1.1:999'], default_tz_uuid=_uuid(), nsx_user='******', nsx_password='******') self.fake_cluster.api_client = NvpApiClient.NVPApiHelper( ('1.1.1.1', '999', True), self.fake_cluster.nsx_user, self.fake_cluster.nsx_password, self.fake_cluster.req_timeout, self.fake_cluster.http_timeout, self.fake_cluster.retries, self.fake_cluster.redirects) # Instantiate Neutron plugin # and setup needed config variables args = [ '--config-file', get_fake_conf('neutron.conf.test'), '--config-file', get_fake_conf('nsx.ini.test') ] config.parse(args=args) cfg.CONF.set_override('allow_overlapping_ips', True) self._plugin = NeutronPlugin.NvpPluginV2() # Mock neutron manager plugin load functions to speed up tests mock_nm_get_plugin = mock.patch('neutron.manager.NeutronManager.' 'get_plugin') mock_nm_get_service_plugins = mock.patch( 'neutron.manager.NeutronManager.get_service_plugins') self.mock_nm_get_plugin = mock_nm_get_plugin.start() self.mock_nm_get_plugin.return_value = self._plugin mock_nm_get_service_plugins.start() super(NvpSyncTestCase, self).setUp() self.addCleanup(self.fc.reset_all) self.addCleanup(patch_sync.stop) self.addCleanup(mock_nvpapi.stop) self.addCleanup(mock_nm_get_plugin.stop) self.addCleanup(mock_nm_get_service_plugins.stop)
def setUp(self): test_config['plugin_name_v2'] = PLUGIN_NAME test_config['config_files'] = [get_fake_conf('nvp.ini.full.test')] # mock nvp api client self.fc = fake_nvpapiclient.FakeClient(STUBS_PATH) self.mock_nvpapi = mock.patch(NVPAPI_NAME, autospec=True) instance = self.mock_nvpapi.start() def _fake_request(*args, **kwargs): return self.fc.fake_request(*args, **kwargs) # Emulate tests against NVP 2.x instance.return_value.get_nvp_version.return_value = "2.999" instance.return_value.request.side_effect = _fake_request super(NVPDhcpAgentNotifierTestCase, self).setUp() self.addCleanup(self.fc.reset_all) self.addCleanup(self.mock_nvpapi.stop)
def setUp(self): test_config['config_files'] = [get_fake_conf('nsx.ini.full.test')] # mock nvp api client self.fc = fake_nvpapiclient.FakeClient(STUBS_PATH) self.mock_nvpapi = mock.patch(NVPAPI_NAME, autospec=True) instance = self.mock_nvpapi.start() # Avoid runs of the synchronizer looping call patch_sync = mock.patch.object(sync, '_start_loopingcall') patch_sync.start() def _fake_request(*args, **kwargs): return self.fc.fake_request(*args, **kwargs) # Emulate tests against NVP 2.x instance.return_value.get_nvp_version.return_value = "2.999" instance.return_value.request.side_effect = _fake_request super(NVPDhcpAgentNotifierTestCase, self).setUp() self.addCleanup(self.fc.reset_all) self.addCleanup(patch_sync.stop) self.addCleanup(self.mock_nvpapi.stop) self.addCleanup(cfg.CONF.reset)