Fix some unittests global issues
1) Mock RPC calls in unittests 2) Remove duplicate dictionary key in one of the tests 3) Fix mock usage in one test to make pep8 happy Change-Id: I6050a18c8188cacf776f98530e43f1455df805a0
This commit is contained in:
parent
5b5ff8b059
commit
2497f06add
@ -40,7 +40,6 @@ NVP_INI_DEPR_PATH = vmware.get_fake_conf('nvp.ini.full.test')
|
|||||||
class NSXClusterTest(base.BaseTestCase):
|
class NSXClusterTest(base.BaseTestCase):
|
||||||
|
|
||||||
cluster_opts = {'default_tz_uuid': uuidutils.generate_uuid(),
|
cluster_opts = {'default_tz_uuid': uuidutils.generate_uuid(),
|
||||||
'default_l2_gw_service_uuid': uuidutils.generate_uuid(),
|
|
||||||
'default_l2_gw_service_uuid': uuidutils.generate_uuid(),
|
'default_l2_gw_service_uuid': uuidutils.generate_uuid(),
|
||||||
'nsx_user': 'foo',
|
'nsx_user': 'foo',
|
||||||
'nsx_password': 'bar',
|
'nsx_password': 'bar',
|
||||||
@ -92,7 +91,7 @@ class ConfigurationTest(base.BaseTestCase):
|
|||||||
self.assertEqual('whatever', cluster.nsx_default_interface_name)
|
self.assertEqual('whatever', cluster.nsx_default_interface_name)
|
||||||
|
|
||||||
def _get_mh_plugin(self):
|
def _get_mh_plugin(self):
|
||||||
with mock.patch("neutron.common.rpc.Connection"):
|
with mock.patch("neutron_lib.rpc.Connection"):
|
||||||
plugin = mh_plugin.NsxPlugin()
|
plugin = mh_plugin.NsxPlugin()
|
||||||
return plugin
|
return plugin
|
||||||
|
|
||||||
@ -249,7 +248,7 @@ class OldNVPConfigurationTest(base.BaseTestCase):
|
|||||||
self.config_parse(args=['--config-file', BASE_CONF_PATH,
|
self.config_parse(args=['--config-file', BASE_CONF_PATH,
|
||||||
'--config-file', NVP_INI_DEPR_PATH])
|
'--config-file', NVP_INI_DEPR_PATH])
|
||||||
cfg.CONF.set_override('core_plugin', vmware.PLUGIN_NAME)
|
cfg.CONF.set_override('core_plugin', vmware.PLUGIN_NAME)
|
||||||
with mock.patch("neutron.common.rpc.Connection"):
|
with mock.patch("neutron_lib.rpc.Connection"):
|
||||||
plugin = mh_plugin.NsxPlugin()
|
plugin = mh_plugin.NsxPlugin()
|
||||||
cluster = plugin.cluster
|
cluster = plugin.cluster
|
||||||
# Verify old nvp_* params have been fully parsed
|
# Verify old nvp_* params have been fully parsed
|
||||||
|
@ -295,7 +295,7 @@ class SyncTestCase(testlib_api.SqlTestCase):
|
|||||||
self.config_parse(args=args)
|
self.config_parse(args=args)
|
||||||
cfg.CONF.set_override('allow_overlapping_ips', True)
|
cfg.CONF.set_override('allow_overlapping_ips', True)
|
||||||
|
|
||||||
with mock.patch("neutron.common.rpc.Connection"):
|
with mock.patch("neutron_lib.rpc.Connection"):
|
||||||
self._plugin = plugin.NsxPlugin()
|
self._plugin = plugin.NsxPlugin()
|
||||||
|
|
||||||
mock_nm_get_plugin = mock.patch(
|
mock_nm_get_plugin = mock.patch(
|
||||||
|
@ -218,6 +218,9 @@ class NsxVPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
|
|||||||
mock_deploy_backup_edges_at_backend = mock.patch("%s.%s" % (
|
mock_deploy_backup_edges_at_backend = mock.patch("%s.%s" % (
|
||||||
vmware.EDGE_MANAGE_NAME, '_deploy_backup_edges_at_backend'))
|
vmware.EDGE_MANAGE_NAME, '_deploy_backup_edges_at_backend'))
|
||||||
mock_deploy_backup_edges_at_backend.start()
|
mock_deploy_backup_edges_at_backend.start()
|
||||||
|
mock.patch(
|
||||||
|
'neutron_lib.rpc.Connection.consume_in_threads',
|
||||||
|
return_value=[]).start()
|
||||||
|
|
||||||
self.default_res_pool = 'respool-28'
|
self.default_res_pool = 'respool-28'
|
||||||
cfg.CONF.set_override("resource_pool_id", self.default_res_pool,
|
cfg.CONF.set_override("resource_pool_id", self.default_res_pool,
|
||||||
@ -1317,16 +1320,16 @@ class TestPortsV2(NsxVPluginV2TestCase,
|
|||||||
res = self.deserialize('json', req.get_response(self.api))
|
res = self.deserialize('json', req.get_response(self.api))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@mock.patch.object(edge_utils.EdgeManager, 'delete_dhcp_binding')
|
|
||||||
def _test_update_port_index_and_spoofguard(
|
def _test_update_port_index_and_spoofguard(
|
||||||
self, ip_version, subnet_cidr, port_ip, port_mac, ipv6_lla,
|
self, ip_version, subnet_cidr, port_ip, port_mac, ipv6_lla):
|
||||||
delete_dhcp_binding):
|
|
||||||
q_context = context.Context('', 'tenant_1')
|
q_context = context.Context('', 'tenant_1')
|
||||||
device_id = _uuid()
|
device_id = _uuid()
|
||||||
with self.subnet(ip_version=ip_version,
|
with self.subnet(ip_version=ip_version,
|
||||||
enable_dhcp=(False if ip_version == 6 else True),
|
enable_dhcp=(False if ip_version == 6 else True),
|
||||||
cidr=subnet_cidr,
|
cidr=subnet_cidr,
|
||||||
gateway_ip=None) as subnet:
|
gateway_ip=None) as subnet, \
|
||||||
|
mock.patch.object(edge_utils.EdgeManager,
|
||||||
|
'delete_dhcp_binding') as delete_dhcp_binding:
|
||||||
fixed_ip_data = [{'ip_address': port_ip,
|
fixed_ip_data = [{'ip_address': port_ip,
|
||||||
'subnet_id': subnet['subnet']['id']}]
|
'subnet_id': subnet['subnet']['id']}]
|
||||||
with self.port(subnet=subnet,
|
with self.port(subnet=subnet,
|
||||||
|
@ -211,6 +211,9 @@ class NsxV3PluginTestCaseMixin(test_plugin.NeutronDbPluginV2TestCase,
|
|||||||
nsx_plugin.NsxV3Plugin, '_get_edge_cluster',
|
nsx_plugin.NsxV3Plugin, '_get_edge_cluster',
|
||||||
return_value=uuidutils.generate_uuid())
|
return_value=uuidutils.generate_uuid())
|
||||||
mock_get_edge_cluster.start()
|
mock_get_edge_cluster.start()
|
||||||
|
mock.patch(
|
||||||
|
'neutron_lib.rpc.Connection.consume_in_threads',
|
||||||
|
return_value=[]).start()
|
||||||
|
|
||||||
def setUp(self, plugin=PLUGIN_NAME,
|
def setUp(self, plugin=PLUGIN_NAME,
|
||||||
ext_mgr=None,
|
ext_mgr=None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user