From fb56e513a78eca6017fbf1d7543126d1153aea86 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 2 Jan 2013 13:16:33 +0000 Subject: Fix publish_errors unit test The unit test for publish_errors=True causes logging to be spewed from other tests because it configures the default root logger rather than creating its own logger like other logging tests do. This makes the unit tests completely silent again. Also, it hooked into the rpc notifier to catch notifications when it can simple hook into the no-op notifier like other tests. Finally, it used stubout to override the value of config options rather than the BaseTestCase.config() helper method. Change-Id: I13313fcd9ad8f9e5bcb9af90652b5dde5c3feec9 --- tests/unit/test_notifier.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/unit/test_notifier.py b/tests/unit/test_notifier.py index 1cabae0..c01bf3d 100644 --- a/tests/unit/test_notifier.py +++ b/tests/unit/test_notifier.py @@ -111,17 +111,18 @@ class NotifierTestCase(test_utils.BaseTestCase): self.assertEqual(self.test_topic, 'testnotify.debug') def test_error_notification(self): - self.stubs.Set(cfg.CONF, 'notification_driver', - ['openstack.common.notifier.rabbit_notifier']) - self.stubs.Set(cfg.CONF, 'publish_errors', True) - LOG = log.getLogger('common') - log.setup(None) + self.config(publish_errors=True, + use_stderr=False) + + def mock_notify(context, message): + msgs.append(message) + msgs = [] + self.stubs.Set(no_op_notifier, 'notify', mock_notify) - def mock_notify(context, topic, data): - msgs.append(data) + LOG = log.getLogger('test_error_notification.common') + log.setup('test_error_notification') - self.stubs.Set(rpc, 'notify', mock_notify) LOG.error('foo') self.assertEqual(1, len(msgs)) msg = msgs[0] -- cgit