simplify crud notification test

test_alarms_sends_notification will hang forever if it fails.
we don't really need to test that its notification is received by
other, just that it sends a notification. drop the test so it
verifies only that.

also, uncap pbr to resolve requirements conflict

Change-Id: I99f9996e5a3dd1e652d4142c7b596ae87da5e698
(cherry picked from commit b231f83f38)
This commit is contained in:
gord chung 2017-06-21 16:34:15 +00:00 committed by gordon chung
parent 5c6b46ecc8
commit 0ffb1da9dd
2 changed files with 15 additions and 24 deletions

View File

@ -18,7 +18,6 @@ import datetime
import os
import mock
import oslo_messaging.conffixture
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
import six
@ -1707,30 +1706,22 @@ class TestAlarms(TestAlarmsBase):
}
}
endpoint = mock.MagicMock()
target = oslo_messaging.Target(topic="notifications")
listener = messaging.get_batch_notification_listener(
self.transport, [target], [endpoint])
listener.start()
endpoint.info.side_effect = lambda *args: listener.stop()
self.post_json('/alarms', params=json, headers=self.auth_headers)
listener.wait()
class NotificationsMatcher(object):
def __eq__(self, notifications):
payload = notifications[0]['payload']
return (payload['detail']['name'] == 'sent_notification' and
payload['type'] == 'creation' and
payload['detail']['rule']['meter_name'] == 'ameter' and
set(['alarm_id', 'detail', 'event_id', 'on_behalf_of',
'project_id', 'timestamp',
with mock.patch.object(messaging, 'get_notifier') as get_notifier:
notifier = get_notifier.return_value
self.post_json('/alarms', params=json, headers=self.auth_headers)
get_notifier.assert_called_once_with(mock.ANY,
publisher_id='aodh.api')
calls = notifier.info.call_args_list
self.assertEqual(1, len(calls))
args, _ = calls[0]
context, event_type, payload = args
self.assertEqual('alarm.creation', event_type)
self.assertEqual('sent_notification', payload['detail']['name'])
self.assertEqual('ameter', payload['detail']['rule']['meter_name'])
self.assertTrue(set(['alarm_id', 'detail', 'event_id', 'on_behalf_of',
'project_id', 'timestamp', 'type',
'user_id']).issubset(payload.keys()))
def __ne__(self, other):
return not self.__eq__(other)
endpoint.info.assert_called_once_with(NotificationsMatcher())
def test_alarm_sends_notification(self):
with mock.patch.object(messaging, 'get_notifier') as get_notifier:
notifier = get_notifier.return_value

View File

@ -16,7 +16,7 @@ oslo.i18n>=1.5.0,<3.13.0 # Apache-2.0
oslo.log>=1.2.0 # Apache-2.0
oslo.policy>=0.5.0 # Apache-2.0
PasteDeploy>=1.5.0
pbr>=1.8,<2.0.0
pbr>=1.8
pecan>=0.8.0
oslo.messaging>=5.2.0 # Apache-2.0
oslo.middleware>=3.22.0,<3.24.0 # Apache-2.0