diff options
| author | Naveed Massjouni <naveedm9@gmail.com> | 2011-06-02 17:33:40 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-06-02 17:33:40 +0000 |
| commit | 43561799ce54515552f7d14ee7df067c136b490c (patch) | |
| tree | 14957ead831d67839948d87690411efcabd98117 /nova/tests | |
| parent | 6b40a9175f55fddc1350b40b995c11cdfc4a8220 (diff) | |
| parent | 9fc8e71f1b201adc0a5e49ac3a94e22bf47596fb (diff) | |
This adds the ability to publish nova errors to an error queue.
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_notifier.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/nova/tests/test_notifier.py b/nova/tests/test_notifier.py index b6b0fcc68..64b799a2c 100644 --- a/nova/tests/test_notifier.py +++ b/nova/tests/test_notifier.py @@ -13,10 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. -import nova +import stubout +import nova from nova import context from nova import flags +from nova import log from nova import rpc import nova.notifier.api from nova.notifier.api import notify @@ -24,8 +26,6 @@ from nova.notifier import no_op_notifier from nova.notifier import rabbit_notifier from nova import test -import stubout - class NotifierTestCase(test.TestCase): """Test case for notifications""" @@ -115,3 +115,22 @@ class NotifierTestCase(test.TestCase): notify('publisher_id', 'event_type', 'DEBUG', dict(a=3)) self.assertEqual(self.test_topic, 'testnotify.debug') + + def test_error_notification(self): + self.stubs.Set(nova.flags.FLAGS, 'notification_driver', + 'nova.notifier.rabbit_notifier') + self.stubs.Set(nova.flags.FLAGS, 'publish_errors', True) + LOG = log.getLogger('nova') + LOG.setup_from_flags() + msgs = [] + + def mock_cast(context, topic, data): + msgs.append(data) + + self.stubs.Set(nova.rpc, 'cast', mock_cast) + LOG.error('foo') + self.assertEqual(1, len(msgs)) + msg = msgs[0] + self.assertEqual(msg['event_type'], 'error_notification') + self.assertEqual(msg['priority'], 'ERROR') + self.assertEqual(msg['payload']['error'], 'foo') |
