diff --git a/tests/test_notify_dispatcher.py b/tests/test_notify_dispatcher.py index 9e982992b..5006cb807 100644 --- a/tests/test_notify_dispatcher.py +++ b/tests/test_notify_dispatcher.py @@ -115,13 +115,14 @@ class TestDispatcher(test_utils.BaseTestCase): for m in endpoint_methods: if m == self.endpoints_expect_calls[i]: method = getattr(endpoints[i], m) - expected = [mock.call({}, msg['publisher_id'], - msg['event_type'], - msg['payload'], { - 'timestamp': mock.ANY, - 'message_id': mock.ANY - })] - self.assertEqual(method.call_args_list, expected) + method.assert_called_once_with( + {}, + msg['publisher_id'], + msg['event_type'], + msg['payload'], { + 'timestamp': mock.ANY, + 'message_id': mock.ANY + }) else: self.assertEqual(0, endpoints[i].call_count) diff --git a/tests/test_notify_listener.py b/tests/test_notify_listener.py index 608191598..622489619 100644 --- a/tests/test_notify_listener.py +++ b/tests/test_notify_listener.py @@ -150,14 +150,14 @@ class TestNotifyListener(test_utils.BaseTestCase, ListenerSetupMixin): self._stop_listener(listener_thread) - expected = [mock.call({'ctxt': '1'}, 'testpublisher', - 'an_event.start1', 'test', - {'timestamp': mock.ANY, 'message_id': mock.ANY}), - mock.call({'ctxt': '2'}, 'testpublisher', - 'an_event.start2', 'test', - {'timestamp': mock.ANY, 'message_id': mock.ANY})] - - self.assertEqual(sorted(endpoint.info.call_args_list), expected) + endpoint.info.assert_has_calls([ + mock.call({'ctxt': '1'}, 'testpublisher', + 'an_event.start1', 'test', + {'timestamp': mock.ANY, 'message_id': mock.ANY}), + mock.call({'ctxt': '2'}, 'testpublisher', + 'an_event.start2', 'test', + {'timestamp': mock.ANY, 'message_id': mock.ANY})], + any_order=True) def test_two_exchanges(self): transport = messaging.get_transport(self.conf, url='fake:') @@ -192,13 +192,14 @@ class TestNotifyListener(test_utils.BaseTestCase, ListenerSetupMixin): self._stop_listener(listener_thread) - expected = [mock.call({'ctxt': '1'}, 'testpublisher', 'an_event.start', - 'test message exchange1', - {'timestamp': mock.ANY, 'message_id': mock.ANY}), - mock.call({'ctxt': '2'}, 'testpublisher', 'an_event.start', - 'test message exchange2', - {'timestamp': mock.ANY, 'message_id': mock.ANY})] - self.assertEqual(sorted(endpoint.info.call_args_list), expected) + endpoint.info.assert_has_calls([ + mock.call({'ctxt': '1'}, 'testpublisher', 'an_event.start', + 'test message exchange1', + {'timestamp': mock.ANY, 'message_id': mock.ANY}), + mock.call({'ctxt': '2'}, 'testpublisher', 'an_event.start', + 'test message exchange2', + {'timestamp': mock.ANY, 'message_id': mock.ANY})], + any_order=True) def test_two_endpoints(self): transport = messaging.get_transport(self.conf, url='fake:') @@ -242,8 +243,8 @@ class TestNotifyListener(test_utils.BaseTestCase, ListenerSetupMixin): self._stop_listener(listener_thread) - expected = [mock.call({}, 'testpublisher', 'an_event.start', 'test', - {'timestamp': mock.ANY, 'message_id': mock.ANY}), - mock.call({}, 'testpublisher', 'an_event.start', 'test', - {'timestamp': mock.ANY, 'message_id': mock.ANY})] - self.assertEqual(endpoint.info.call_args_list, expected) + endpoint.info.assert_has_calls([ + mock.call({}, 'testpublisher', 'an_event.start', 'test', + {'timestamp': mock.ANY, 'message_id': mock.ANY}), + mock.call({}, 'testpublisher', 'an_event.start', 'test', + {'timestamp': mock.ANY, 'message_id': mock.ANY})])