def setUp(self): self.mock_api = mock.patch( 'neutron.plugins.midonet.midonet_lib.MidoClient') etc_path = os.path.join(os.path.dirname(__file__), 'etc') test_lib.test_config['config_files'] = [ os.path.join(etc_path, 'midonet.ini.test') ] self.instance = self.mock_api.start() mock_cfg = mock_lib.MidonetLibMockConfig(self.instance.return_value) mock_cfg.setup() p = mock.patch.dict(sys.modules, {'midonetclient': mock.Mock()}) p.start() # dict patches must be explicitly stopped self.addCleanup(p.stop) self.midoclient_mock = mock.MagicMock() self.midoclient_mock.midonetclient.neutron.client.return_value = True modules = { 'midonetclient': self.midoclient_mock, 'midonetclient.neutron': self.midoclient_mock.neutron, 'midonetclient.neutron.client': self.midoclient_mock.client, } self.module_patcher = mock.patch.dict('sys.modules', modules) self.module_patcher.start() self.addCleanup(self.module_patcher.stop) # import midonetclient here because it needs proper mock objects to be # assigned to this module first. 'midoclient_mock' object is the # mock object used for this module. from midonetclient.neutron.client import MidonetClient client_class = MidonetClient self.mock_class = client_class() super(TestMidonetSecurityGroupsTestCase, self).setUp(self._plugin_name)
def setUp(self): self.mock_api = mock.patch( 'neutron.plugins.midonet.midonet_lib.MidoClient') etc_path = os.path.join(os.path.dirname(__file__), 'etc') test_lib.test_config['config_files'] = [os.path.join( etc_path, 'midonet.ini.test')] self.instance = self.mock_api.start() mock_cfg = mock_lib.MidonetLibMockConfig(self.instance.return_value) mock_cfg.setup() super(MidonetPluginV2TestCase, self).setUp(self._plugin_name)
def setUp(self, plugin=MIDONET_PLUGIN_NAME, ext_mgr=None, service_plugins=None): self.mock_api = mock.patch( 'neutron.plugins.midonet.midonet_lib.MidoClient') etc_path = os.path.join(os.path.dirname(__file__), 'etc') test_lib.test_config['config_files'] = [ os.path.join(etc_path, 'midonet.ini.test') ] self.instance = self.mock_api.start() mock_cfg = mock_lib.MidonetLibMockConfig(self.instance.return_value) mock_cfg.setup() super(MidonetPluginV2TestCase, self).setUp(plugin=plugin, ext_mgr=ext_mgr)
def setUp(self): self.mock_api = mock.patch( 'neutron.plugins.midonet.midonet_lib.MidoClient') etc_path = os.path.join(os.path.dirname(__file__), 'etc') test_lib.test_config['config_files'] = [ os.path.join(etc_path, 'midonet.ini.test') ] self.instance = self.mock_api.start() mock_cfg = mock_lib.MidonetLibMockConfig(self.instance.return_value) mock_cfg.setup() p = mock.patch.dict(sys.modules, {'midonetclient': mock.Mock()}) p.start() # dict patches must be explicitly stopped self.addCleanup(p.stop) super(TestMidonetSecurityGroupsTestCase, self).setUp(self._plugin_name)
def setUp(self, plugin=MIDONET_PLUGIN_NAME, ext_mgr=None, service_plugins=None): self.mock_api = mock.patch( 'neutron.plugins.midonet.midonet_lib.MidoClient') etc_path = os.path.join(os.path.dirname(__file__), 'etc') test_lib.test_config['config_files'] = [ os.path.join(etc_path, 'midonet.ini.test') ] p = mock.patch.dict(sys.modules, {'midonetclient': mock.Mock()}) p.start() # dict patches must be explicitly stopped self.addCleanup(p.stop) self.instance = self.mock_api.start() mock_cfg = mock_lib.MidonetLibMockConfig(self.instance.return_value) mock_cfg.setup() super(MidonetPluginV2TestCase, self).setUp(plugin=plugin, ext_mgr=ext_mgr)