summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorStanislaw Pitucha <stanislaw.pitucha@hp.com>2012-08-04 14:12:49 +0100
committerStanislaw Pitucha <stanislaw.pitucha@hp.com>2012-08-04 14:12:49 +0100
commit662cc871c8aaa96fea26c0eab75fed09e2995ee6 (patch)
treef1eab23356cea4e4565e9958cd826657262913fb /nova/tests
parentff9578da2d042ba3d6cb7b6ded76de74c0754689 (diff)
Fix notification logic
Notifications were always treated as if they're about state changes due to a typo. Additionally exception handler did not work correctly. Regression tests included. Change-Id: I0b92a1baa17768d9cf4e709b3331480548dd041e
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_notifications.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/nova/tests/test_notifications.py b/nova/tests/test_notifications.py
index 0626f16e8..5fd5d63f9 100644
--- a/nova/tests/test_notifications.py
+++ b/nova/tests/test_notifications.py
@@ -268,3 +268,22 @@ class NotificationsTestCase(test.TestCase):
display_name = self.instance["display_name"]
self.assertEquals(payload["display_name"], display_name)
+
+ def test_send_no_state_change(self):
+ called = [False]
+
+ def sending_no_state_change(context, instance, **kwargs):
+ called[0] = True
+ self.stubs.Set(notifications, '_send_instance_update_notification',
+ sending_no_state_change)
+ notifications.send_update(self.context, self.instance, self.instance)
+ self.assertTrue(called[0])
+
+ def test_fail_sending_update(self):
+ def fail_sending(context, instance, **kwargs):
+ raise Exception('failed to notify')
+ self.stubs.Set(notifications, '_send_instance_update_notification',
+ fail_sending)
+
+ notifications.send_update(self.context, self.instance, self.instance)
+ self.assertEquals(0, len(test_notifier.NOTIFICATIONS))