NSX-V3| fix unittests mock

NSX-lib changed some resources locations

Change-Id: I0a2d8466f177de4eb2be594a075ea9b2a7eb50fe
This commit is contained in:
Adit Sarfaty 2017-03-29 12:05:43 +03:00
parent 1d92ca7c84
commit 4aac83661a
2 changed files with 24 additions and 14 deletions

View File

@ -98,15 +98,17 @@ def _mock_nsx_backend_calls():
side_effect=_return_id_key).start()
mock.patch(
"vmware_nsxlib.v3.NsxLibBridgeCluster.get_id_by_name_or_id",
"vmware_nsxlib.v3.core_resources.NsxLibBridgeCluster."
"get_id_by_name_or_id",
return_value=uuidutils.generate_uuid()).start()
mock.patch(
"vmware_nsxlib.v3.NsxLibTransportZone.get_id_by_name_or_id",
"vmware_nsxlib.v3.core_resources.NsxLibTransportZone."
"get_id_by_name_or_id",
return_value=uuidutils.generate_uuid()).start()
mock.patch(
"vmware_nsxlib.v3.NsxLibBridgeEndpoint.create",
"vmware_nsxlib.v3.core_resources.NsxLibBridgeEndpoint.create",
side_effect=_return_id_key).start()
mock.patch(
@ -114,15 +116,17 @@ def _mock_nsx_backend_calls():
).start()
mock.patch(
"vmware_nsxlib.v3.NsxLibLogicalSwitch.create",
"vmware_nsxlib.v3.core_resources.NsxLibLogicalSwitch.create",
side_effect=_return_id_key).start()
mock.patch(
"vmware_nsxlib.v3.NsxLibDhcpProfile.get_id_by_name_or_id",
"vmware_nsxlib.v3.core_resources.NsxLibDhcpProfile."
"get_id_by_name_or_id",
return_value=NSX_DHCP_PROFILE_ID).start()
mock.patch(
"vmware_nsxlib.v3.NsxLibMetadataProxy.get_id_by_name_or_id",
"vmware_nsxlib.v3.core_resources.NsxLibMetadataProxy."
"get_id_by_name_or_id",
side_effect=_return_same).start()
mock.patch(

View File

@ -92,7 +92,7 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
def test_policy_create_profile(self, fake_db_add, fake_rbac_create):
# test the switch profile creation when a QoS policy is created
with mock.patch(
'vmware_nsxlib.v3.NsxLibQosSwitchingProfile.create',
'vmware_nsxlib.v3.core_resources.NsxLibQosSwitchingProfile.create',
return_value=self.fake_profile
) as create_profile:
with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
@ -120,7 +120,7 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
fields = base_object.get_updatable_fields(
policy_object.QosPolicy, self.policy_data['policy'])
with mock.patch(
'vmware_nsxlib.v3.NsxLibQosSwitchingProfile.update'
'vmware_nsxlib.v3.core_resources.NsxLibQosSwitchingProfile.update'
) as update_profile:
with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
return_value=self.policy):
@ -151,7 +151,8 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
return_value=_policy):
with mock.patch(
'vmware_nsxlib.v3.NsxLibQosSwitchingProfile.update_shaping'
'vmware_nsxlib.v3.core_resources.NsxLibQosSwitchingProfile.'
'update_shaping'
) as update_profile:
with mock.patch('neutron.objects.db.api.update_object',
return_value=self.rule_data):
@ -194,7 +195,8 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
return_value=_policy):
with mock.patch(
'vmware_nsxlib.v3.NsxLibQosSwitchingProfile.update_shaping'
'vmware_nsxlib.v3.core_resources.NsxLibQosSwitchingProfile.'
'update_shaping'
) as update_profile:
with mock.patch('neutron.objects.db.api.update_object',
return_value=rule_data):
@ -236,7 +238,8 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
return_value=_policy):
with mock.patch(
'vmware_nsxlib.v3.NsxLibQosSwitchingProfile.update_shaping'
'vmware_nsxlib.v3.core_resources.NsxLibQosSwitchingProfile.'
'update_shaping'
) as update_profile:
with mock.patch('neutron.objects.db.api.update_object',
return_value=rule_data):
@ -268,7 +271,8 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
return_value=_policy):
with mock.patch(
'vmware_nsxlib.v3.NsxLibQosSwitchingProfile.update_shaping'
'vmware_nsxlib.v3.core_resources.NsxLibQosSwitchingProfile.'
'update_shaping'
) as update_profile:
with mock.patch('neutron.objects.db.api.'
'update_object', return_value=self.dscp_rule_data):
@ -300,7 +304,8 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
return_value=_policy):
with mock.patch(
"vmware_nsxlib.v3.NsxLibQosSwitchingProfile.update_shaping"
'vmware_nsxlib.v3.core_resources.NsxLibQosSwitchingProfile.'
'update_shaping'
) as update_profile:
setattr(_policy, "rules", [self.rule])
self.qos_plugin.delete_policy_bandwidth_limit_rule(
@ -320,7 +325,8 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
def test_policy_delete_profile(self, *mocks):
# test the switch profile deletion when a QoS policy is deleted
with mock.patch(
'vmware_nsxlib.v3.NsxLibQosSwitchingProfile.delete',
'vmware_nsxlib.v3.core_resources.NsxLibQosSwitchingProfile.'
'delete',
return_value=self.fake_profile
) as delete_profile:
self.qos_plugin.delete_policy(self.ctxt, self.policy.id)