From 2d72790bf83473e0c9b73cc290f711fcda7a5803 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Tue, 22 Apr 2014 10:27:49 -0700 Subject: [PATCH] Big Switch: Don't use MagicMocks unnecessarily 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/neutron/tests/unit/bigswitch/test_base.py b/neutron/tests/unit/bigswitch/test_base.py index c927c4277..53be0931e 100644 --- a/neutron/tests/unit/bigswitch/test_base.py +++ b/neutron/tests/unit/bigswitch/test_base.py @@ -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() -- 2.45.2