summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorCerberus <matt.dietz@rackspace.com>2011-05-11 10:42:51 -0500
committerCerberus <matt.dietz@rackspace.com>2011-05-11 10:42:51 -0500
commitd4c42ca05bce95dd385a3ab2f661ca19043ba66f (patch)
tree62a7c3c0c9f78bde59ce64cdf2e0f9df2c44bd2b /nova/tests
parent3f7cf0826a4edfd93aac20d677d05153ca072c61 (diff)
parente1dc9cfb521f21dd0cdd4d9771d78ef5024cebad (diff)
Merge from Dragon
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_notifier.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/nova/tests/test_notifier.py b/nova/tests/test_notifier.py
index 640a0cb34..d2964c42f 100644
--- a/nova/tests/test_notifier.py
+++ b/nova/tests/test_notifier.py
@@ -13,13 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
import nova
+from nova import context
from nova import flags
+from nova import rpc
from nova import notifier
from nova.notifier import no_op_notifier
+from nova.notifier import rabbit_notifier
from nova import test
import stubout
@@ -51,8 +52,7 @@ class NotifierTestCase(test.TestCase):
def test_verify_message_format(self):
"""A test to ensure changing the message format is prohibitively
annoying"""
- def message_assert(cls, blob):
- message = json.loads(blob)
+ def message_assert(cls, message):
fields = [('publisher_id', 'publisher_id'),
('event_type', 'event_type'),
('priority', 'WARN'),
@@ -72,7 +72,7 @@ class NotifierTestCase(test.TestCase):
self.mock_cast = False
def mock_cast(cls, *args):
self.mock_cast = True
-
+
class Mock(object):
pass
self.stubs.Set(nova.rpc, 'cast', mock_cast)
@@ -84,7 +84,7 @@ class NotifierTestCase(test.TestCase):
def test_invalid_priority(self):
def mock_cast(cls, *args):
pass
-
+
class Mock(object):
pass
@@ -92,3 +92,20 @@ class NotifierTestCase(test.TestCase):
self.assertRaises(nova.notifier.BadPriorityException,
nova.notifier.notify, 'event_name', 'publisher_id',
'event_type', 'not a priority', dict(a=3))
+
+ def test_rabbit_priority_queue(self):
+ self.stubs.Set(nova.flags.FLAGS, 'notification_driver',
+ 'nova.notifier.rabbit_notifier.RabbitNotifier')
+ self.stubs.Set(nova.flags.FLAGS, 'notification_topic',
+ 'testnotify')
+
+ self.test_topic = None
+
+ def mock_cast(context, topic, msg):
+ self.test_topic = topic
+
+ self.stubs.Set(nova.rpc, 'cast', mock_cast)
+ nova.notifier.notify('event_name', 'publisher_id',
+ 'event_type', 'DEBUG', dict(a=3))
+ self.assertEqual(self.test_topic, 'testnotify.debug')
+