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:
Adit Sarfaty 2018-10-14 15:20:14 +03:00
parent 5b5ff8b059
commit 2497f06add
4 changed files with 13 additions and 8 deletions

View File

@ -40,7 +40,6 @@ NVP_INI_DEPR_PATH = vmware.get_fake_conf('nvp.ini.full.test')
class NSXClusterTest(base.BaseTestCase):
cluster_opts = {'default_tz_uuid': uuidutils.generate_uuid(),
'default_l2_gw_service_uuid': uuidutils.generate_uuid(),
'default_l2_gw_service_uuid': uuidutils.generate_uuid(),
'nsx_user': 'foo',
'nsx_password': 'bar',
@ -92,7 +91,7 @@ class ConfigurationTest(base.BaseTestCase):
self.assertEqual('whatever', cluster.nsx_default_interface_name)
def _get_mh_plugin(self):
with mock.patch("neutron.common.rpc.Connection"):
with mock.patch("neutron_lib.rpc.Connection"):
plugin = mh_plugin.NsxPlugin()
return plugin
@ -249,7 +248,7 @@ class OldNVPConfigurationTest(base.BaseTestCase):
self.config_parse(args=['--config-file', BASE_CONF_PATH,
'--config-file', NVP_INI_DEPR_PATH])
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()
cluster = plugin.cluster
# Verify old nvp_* params have been fully parsed

View File

@ -295,7 +295,7 @@ class SyncTestCase(testlib_api.SqlTestCase):
self.config_parse(args=args)
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()
mock_nm_get_plugin = mock.patch(

View File

@ -218,6 +218,9 @@ class NsxVPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
mock_deploy_backup_edges_at_backend = mock.patch("%s.%s" % (
vmware.EDGE_MANAGE_NAME, '_deploy_backup_edges_at_backend'))
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'
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))
return res
@mock.patch.object(edge_utils.EdgeManager, 'delete_dhcp_binding')
def _test_update_port_index_and_spoofguard(
self, ip_version, subnet_cidr, port_ip, port_mac, ipv6_lla,
delete_dhcp_binding):
self, ip_version, subnet_cidr, port_ip, port_mac, ipv6_lla):
q_context = context.Context('', 'tenant_1')
device_id = _uuid()
with self.subnet(ip_version=ip_version,
enable_dhcp=(False if ip_version == 6 else True),
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,
'subnet_id': subnet['subnet']['id']}]
with self.port(subnet=subnet,

View File

@ -211,6 +211,9 @@ class NsxV3PluginTestCaseMixin(test_plugin.NeutronDbPluginV2TestCase,
nsx_plugin.NsxV3Plugin, '_get_edge_cluster',
return_value=uuidutils.generate_uuid())
mock_get_edge_cluster.start()
mock.patch(
'neutron_lib.rpc.Connection.consume_in_threads',
return_value=[]).start()
def setUp(self, plugin=PLUGIN_NAME,
ext_mgr=None,