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:
parent
5c6b46ecc8
commit
0ffb1da9dd
@ -18,7 +18,6 @@ import datetime
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import oslo_messaging.conffixture
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
import six
|
||||||
@ -1707,30 +1706,22 @@ class TestAlarms(TestAlarmsBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
endpoint = mock.MagicMock()
|
with mock.patch.object(messaging, 'get_notifier') as get_notifier:
|
||||||
target = oslo_messaging.Target(topic="notifications")
|
notifier = get_notifier.return_value
|
||||||
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)
|
self.post_json('/alarms', params=json, headers=self.auth_headers)
|
||||||
listener.wait()
|
get_notifier.assert_called_once_with(mock.ANY,
|
||||||
|
publisher_id='aodh.api')
|
||||||
class NotificationsMatcher(object):
|
calls = notifier.info.call_args_list
|
||||||
def __eq__(self, notifications):
|
self.assertEqual(1, len(calls))
|
||||||
payload = notifications[0]['payload']
|
args, _ = calls[0]
|
||||||
return (payload['detail']['name'] == 'sent_notification' and
|
context, event_type, payload = args
|
||||||
payload['type'] == 'creation' and
|
self.assertEqual('alarm.creation', event_type)
|
||||||
payload['detail']['rule']['meter_name'] == 'ameter' and
|
self.assertEqual('sent_notification', payload['detail']['name'])
|
||||||
set(['alarm_id', 'detail', 'event_id', 'on_behalf_of',
|
self.assertEqual('ameter', payload['detail']['rule']['meter_name'])
|
||||||
'project_id', 'timestamp',
|
self.assertTrue(set(['alarm_id', 'detail', 'event_id', 'on_behalf_of',
|
||||||
|
'project_id', 'timestamp', 'type',
|
||||||
'user_id']).issubset(payload.keys()))
|
'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):
|
def test_alarm_sends_notification(self):
|
||||||
with mock.patch.object(messaging, 'get_notifier') as get_notifier:
|
with mock.patch.object(messaging, 'get_notifier') as get_notifier:
|
||||||
notifier = get_notifier.return_value
|
notifier = get_notifier.return_value
|
||||||
|
@ -16,7 +16,7 @@ oslo.i18n>=1.5.0,<3.13.0 # Apache-2.0
|
|||||||
oslo.log>=1.2.0 # Apache-2.0
|
oslo.log>=1.2.0 # Apache-2.0
|
||||||
oslo.policy>=0.5.0 # Apache-2.0
|
oslo.policy>=0.5.0 # Apache-2.0
|
||||||
PasteDeploy>=1.5.0
|
PasteDeploy>=1.5.0
|
||||||
pbr>=1.8,<2.0.0
|
pbr>=1.8
|
||||||
pecan>=0.8.0
|
pecan>=0.8.0
|
||||||
oslo.messaging>=5.2.0 # Apache-2.0
|
oslo.messaging>=5.2.0 # Apache-2.0
|
||||||
oslo.middleware>=3.22.0,<3.24.0 # Apache-2.0
|
oslo.middleware>=3.22.0,<3.24.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user