Mock 'oslo_messaging.notify._impl_routing.LOG' in notifier tests

When running the tests with concurrency=1, 2 tests fail with:

  AttributeError: Mock object has no attribute 'debug'

and

  AssertionError: Expected 'notify' to be called once. Called 0 times

Mocking the LOG object solves the problem.

Change-Id: Ie7f4448a103fae448123a05bc92e961aac00d6ec
Closes-Bug: #1660393
This commit is contained in:
Thomas Bechtold 2017-04-04 09:09:20 +02:00
parent e1f718d53a
commit f0b4baa707
1 changed files with 15 additions and 10 deletions

View File

@ -441,10 +441,12 @@ group_2:
with mock.patch('stevedore.dispatch.DispatchExtensionManager',
return_value=self._fake_extension_manager(
mock.MagicMock())):
self.router._load_notifiers()
groups = list(self.router.routing_groups.keys())
groups.sort()
self.assertEqual(['group_1', 'group_2'], groups)
with mock.patch('oslo_messaging.notify.'
'_impl_routing.LOG'):
self.router._load_notifiers()
groups = list(self.router.routing_groups.keys())
groups.sort()
self.assertEqual(['group_1', 'group_2'], groups)
def test_get_drivers_for_message_accepted_events(self):
config = r"""
@ -593,12 +595,15 @@ group_1:
config_file):
with mock.patch('stevedore.dispatch.DispatchExtensionManager',
return_value=pm):
self.notifier.info({}, 'my_event', {})
self.assertFalse(bar_driver.info.called)
rpc_driver.notify.assert_called_once_with(
{}, mock.ANY, 'INFO', None)
rpc2_driver.notify.assert_called_once_with(
{}, mock.ANY, 'INFO', None)
with mock.patch('oslo_messaging.notify.'
'_impl_routing.LOG'):
self.notifier.info({}, 'my_event', {})
self.assertFalse(bar_driver.info.called)
rpc_driver.notify.assert_called_once_with(
{}, mock.ANY, 'INFO', None)
rpc2_driver.notify.assert_called_once_with(
{}, mock.ANY, 'INFO', None)
class TestNoOpNotifier(test_utils.BaseTestCase):