summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-01-02 13:16:33 +0000
committerMark McLoughlin <markmc@redhat.com>2013-01-03 07:34:00 +0000
commitfb56e513a78eca6017fbf1d7543126d1153aea86 (patch)
tree8414e622e277e401a6e2d60d7ff66c4ea7fc92ff /tests
parentffeb0855085617095f19296770a1223cb5641d1c (diff)
downloadoslo-fb56e513a78eca6017fbf1d7543126d1153aea86.tar.gz
oslo-fb56e513a78eca6017fbf1d7543126d1153aea86.tar.xz
oslo-fb56e513a78eca6017fbf1d7543126d1153aea86.zip
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
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_notifier.py17
1 files changed, 9 insertions, 8 deletions
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]