diff --git a/neutron/tests/unit/plugins/ml2/drivers/agent/test_capabilities.py b/neutron/tests/unit/plugins/ml2/drivers/agent/test_capabilities.py index 313526147b3..34a2bdfae1c 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/agent/test_capabilities.py +++ b/neutron/tests/unit/plugins/ml2/drivers/agent/test_capabilities.py @@ -13,6 +13,7 @@ import mock from neutron_lib.callbacks import events +from neutron_lib import fixture from neutron.plugins.ml2.drivers.agent import capabilities from neutron.tests import base @@ -20,23 +21,25 @@ from neutron.tests import base class CapabilitiesTest(base.BaseTestCase): - # TODO(boden) replace with neutron_lib fixture once working - @mock.patch("neutron_lib.callbacks.manager.CallbacksManager.notify") - def test_notify_init_event(self, mocked_manager): + def setUp(self): + super(CapabilitiesTest, self).setUp() + self._mgr = mock.Mock() + self.useFixture(fixture.CallbackRegistryFixture( + callback_manager=self._mgr)) + + def test_notify_init_event(self): mock_agent_type = mock.Mock() mock_agent = mock.Mock() capabilities.notify_init_event(mock_agent_type, mock_agent) - mocked_manager.assert_called_with(mock_agent_type, - events.AFTER_INIT, - mock_agent, - agent=mock_agent) + self._mgr.notify.assert_called_with(mock_agent_type, + events.AFTER_INIT, + mock_agent, + agent=mock_agent) - # TODO(boden) replace with neutron_lib fixture once working - @mock.patch("neutron_lib.callbacks.manager.CallbacksManager.subscribe") - def test_register(self, mocked_subscribe): + def test_register(self): mock_callback = mock.Mock() mock_agent_type = mock.Mock() capabilities.register(mock_callback, mock_agent_type) - mocked_subscribe.assert_called_with(mock_callback, - mock_agent_type, - events.AFTER_INIT) + self._mgr.subscribe.assert_called_with(mock_callback, + mock_agent_type, + events.AFTER_INIT) diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_capabilities.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_capabilities.py index 70d83757866..6b20c86f4e2 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_capabilities.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_capabilities.py @@ -14,6 +14,7 @@ import mock from neutron_lib.callbacks import events +from neutron_lib import fixture from neutron.plugins.ml2.drivers.openvswitch.agent import ovs_capabilities from neutron.services.trunk.drivers.openvswitch.agent import driver @@ -23,10 +24,14 @@ from neutron_lib import constants class CapabilitiesTest(base.BaseTestCase): - # TODO(boden) replace with neutron_lib fixture once working - @mock.patch("neutron_lib.callbacks.manager.CallbacksManager.subscribe") - def test_register(self, mocked_subscribe): + def setUp(self): + super(CapabilitiesTest, self).setUp() + self._mgr = mock.Mock() + self.useFixture(fixture.CallbackRegistryFixture( + callback_manager=self._mgr)) + + def test_register(self): ovs_capabilities.register() - mocked_subscribe.assert_called_with(driver.init_handler, + self._mgr.subscribe.assert_called_with(driver.init_handler, constants.AGENT_TYPE_OVS, events.AFTER_INIT) diff --git a/neutron/tests/unit/services/trunk/rpc/test_backend.py b/neutron/tests/unit/services/trunk/rpc/test_backend.py index 2484e5d6e4c..00ec02ed847 100644 --- a/neutron/tests/unit/services/trunk/rpc/test_backend.py +++ b/neutron/tests/unit/services/trunk/rpc/test_backend.py @@ -13,6 +13,7 @@ import mock from neutron_lib.callbacks import events +from neutron_lib import fixture from neutron.api.rpc.callbacks import resource_manager from neutron.services.trunk import callbacks @@ -25,12 +26,13 @@ class ServerSideRpcBackendTest(base.BaseTestCase): # TODO(fitoduarte): add more test to improve coverage of module def setUp(self): super(ServerSideRpcBackendTest, self).setUp() + self._mgr = mock.Mock() + self.useFixture(fixture.CallbackRegistryFixture( + callback_manager=self._mgr)) self.register_mock = mock.patch.object( resource_manager.ResourceCallbacksManager, "register").start() - # TODO(boden) replace with neutron_lib fixture once working - @mock.patch("neutron_lib.callbacks.manager.CallbacksManager.subscribe") - def test___init__(self, mocked_subscribe): + def test___init__(self,): test_obj = backend.ServerSideRpcBackend() calls = [mock.call(test_obj.process_event, @@ -46,7 +48,7 @@ class ServerSideRpcBackendTest(base.BaseTestCase): trunk_consts.SUBPORTS, events.AFTER_DELETE) ] - mocked_subscribe.assert_has_calls(calls, any_order=True) + self._mgr.subscribe.assert_has_calls(calls, any_order=True) def test_process_event(self): test_obj = backend.ServerSideRpcBackend()