]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Big Switch: Don't use MagicMocks unnecessarily
authorKevin Benton <blak111@gmail.com>
Tue, 22 Apr 2014 17:27:49 +0000 (10:27 -0700)
committerKevin Benton <blak111@gmail.com>
Sat, 10 May 2014 11:27:57 +0000 (04:27 -0700)
Replace the mocks purely being used to block external
calls with functions that just return and don't record
calls.

Closes-Bug: #1315574
Change-Id: I79533135b5cb456d941ddffa62f5365970146a7e

neutron/tests/unit/bigswitch/test_base.py

index c927c4277939ff0b0f63f61e5ace58f61623755f..53be0931e85af7a13682417c36b8de15d2a9e23a 100644 (file)
@@ -28,6 +28,7 @@ from neutron.tests.unit.bigswitch import fake_server
 RESTPROXY_PKG_PATH = 'neutron.plugins.bigswitch.plugin'
 NOTIFIER = 'neutron.plugins.bigswitch.plugin.AgentNotifierApi'
 CALLBACKS = 'neutron.plugins.bigswitch.plugin.RestProxyCallbacks'
+DISPATCHER = CALLBACKS + '.create_rpc_dispatcher'
 CERTFETCH = 'neutron.plugins.bigswitch.servermanager.ServerPool._fetch_cert'
 SERVER_MANAGER = 'neutron.plugins.bigswitch.servermanager'
 HTTPCON = 'neutron.plugins.bigswitch.servermanager.httplib.HTTPConnection'
@@ -54,9 +55,13 @@ class BigSwitchTestBase(object):
 
     def setup_patches(self):
         self.plugin_notifier_p = mock.patch(NOTIFIER)
-        self.callbacks_p = mock.patch(CALLBACKS)
-        self.spawn_p = mock.patch(SPAWN)
-        self.watch_p = mock.patch(CWATCH)
+        # prevent rpc callback dispatcher from being created
+        self.callbacks_p = mock.patch(DISPATCHER,
+                                      new=lambda *args, **kwargs: None)
+        # prevent any greenthreads from spawning
+        self.spawn_p = mock.patch(SPAWN, new=lambda *args, **kwargs: None)
+        # prevent the consistency watchdog from starting
+        self.watch_p = mock.patch(CWATCH, new=lambda *args, **kwargs: None)
         self.addCleanup(db.clear_db)
         self.callbacks_p.start()
         self.plugin_notifier_p.start()