]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Stops patching an object method which could be gone at cleanup
authorMiguel Angel Ajo <mangelajo@redhat.com>
Fri, 28 Aug 2015 05:49:28 +0000 (07:49 +0200)
committerMiguel Angel Ajo <mangelajo@redhat.com>
Fri, 28 Aug 2015 05:57:48 +0000 (07:57 +0200)
Stop patching the qos plugin 'notification_driver_manager' method
and instead substitute for a mock since it's destroyed and reloaded
on every test run.

Closes-Bug: #1489716
Change-Id: I0e84b19bba92a7cbef837de7994a605a78936250

neutron/tests/unit/services/qos/test_qos_plugin.py

index 246f5fab17f7ad9786e72cd6b602db4cc101f96b..6dea3bdfa0ec6f0cdd42801f255c762f196cbf2b 100644 (file)
@@ -46,8 +46,7 @@ class TestQosPlugin(base.BaseQosTestCase):
         self.qos_plugin = mgr.get_service_plugins().get(
             constants.QOS)
 
-        self.notif_driver_m = mock.patch.object(
-            self.qos_plugin, 'notification_driver_manager').start()
+        self.qos_plugin.notification_driver_manager = mock.Mock()
 
         self.ctxt = context.Context('fake_user', 'fake_tenant')
         self.policy_data = {
@@ -69,7 +68,8 @@ class TestQosPlugin(base.BaseQosTestCase):
             self.ctxt, **self.rule_data['bandwidth_limit_rule'])
 
     def _validate_notif_driver_params(self, method_name):
-        method = getattr(self.notif_driver_m, method_name)
+        method = getattr(self.qos_plugin.notification_driver_manager,
+                         method_name)
         self.assertTrue(method.called)
         self.assertIsInstance(
             method.call_args[0][1], policy_object.QosPolicy)