Merge "Use mock's call assert methods over call_args_list"
This commit is contained in:
@@ -115,13 +115,14 @@ class TestDispatcher(test_utils.BaseTestCase):
|
|||||||
for m in endpoint_methods:
|
for m in endpoint_methods:
|
||||||
if m == self.endpoints_expect_calls[i]:
|
if m == self.endpoints_expect_calls[i]:
|
||||||
method = getattr(endpoints[i], m)
|
method = getattr(endpoints[i], m)
|
||||||
expected = [mock.call({}, msg['publisher_id'],
|
method.assert_called_once_with(
|
||||||
msg['event_type'],
|
{},
|
||||||
msg['payload'], {
|
msg['publisher_id'],
|
||||||
'timestamp': mock.ANY,
|
msg['event_type'],
|
||||||
'message_id': mock.ANY
|
msg['payload'], {
|
||||||
})]
|
'timestamp': mock.ANY,
|
||||||
self.assertEqual(method.call_args_list, expected)
|
'message_id': mock.ANY
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
self.assertEqual(0, endpoints[i].call_count)
|
self.assertEqual(0, endpoints[i].call_count)
|
||||||
|
|
||||||
|
|||||||
@@ -150,14 +150,14 @@ class TestNotifyListener(test_utils.BaseTestCase, ListenerSetupMixin):
|
|||||||
|
|
||||||
self._stop_listener(listener_thread)
|
self._stop_listener(listener_thread)
|
||||||
|
|
||||||
expected = [mock.call({'ctxt': '1'}, 'testpublisher',
|
endpoint.info.assert_has_calls([
|
||||||
'an_event.start1', 'test',
|
mock.call({'ctxt': '1'}, 'testpublisher',
|
||||||
{'timestamp': mock.ANY, 'message_id': mock.ANY}),
|
'an_event.start1', 'test',
|
||||||
mock.call({'ctxt': '2'}, 'testpublisher',
|
{'timestamp': mock.ANY, 'message_id': mock.ANY}),
|
||||||
'an_event.start2', 'test',
|
mock.call({'ctxt': '2'}, 'testpublisher',
|
||||||
{'timestamp': mock.ANY, 'message_id': mock.ANY})]
|
'an_event.start2', 'test',
|
||||||
|
{'timestamp': mock.ANY, 'message_id': mock.ANY})],
|
||||||
self.assertEqual(sorted(endpoint.info.call_args_list), expected)
|
any_order=True)
|
||||||
|
|
||||||
def test_two_exchanges(self):
|
def test_two_exchanges(self):
|
||||||
transport = messaging.get_transport(self.conf, url='fake:')
|
transport = messaging.get_transport(self.conf, url='fake:')
|
||||||
@@ -192,13 +192,14 @@ class TestNotifyListener(test_utils.BaseTestCase, ListenerSetupMixin):
|
|||||||
|
|
||||||
self._stop_listener(listener_thread)
|
self._stop_listener(listener_thread)
|
||||||
|
|
||||||
expected = [mock.call({'ctxt': '1'}, 'testpublisher', 'an_event.start',
|
endpoint.info.assert_has_calls([
|
||||||
'test message exchange1',
|
mock.call({'ctxt': '1'}, 'testpublisher', 'an_event.start',
|
||||||
{'timestamp': mock.ANY, 'message_id': mock.ANY}),
|
'test message exchange1',
|
||||||
mock.call({'ctxt': '2'}, 'testpublisher', 'an_event.start',
|
{'timestamp': mock.ANY, 'message_id': mock.ANY}),
|
||||||
'test message exchange2',
|
mock.call({'ctxt': '2'}, 'testpublisher', 'an_event.start',
|
||||||
{'timestamp': mock.ANY, 'message_id': mock.ANY})]
|
'test message exchange2',
|
||||||
self.assertEqual(sorted(endpoint.info.call_args_list), expected)
|
{'timestamp': mock.ANY, 'message_id': mock.ANY})],
|
||||||
|
any_order=True)
|
||||||
|
|
||||||
def test_two_endpoints(self):
|
def test_two_endpoints(self):
|
||||||
transport = messaging.get_transport(self.conf, url='fake:')
|
transport = messaging.get_transport(self.conf, url='fake:')
|
||||||
@@ -242,8 +243,8 @@ class TestNotifyListener(test_utils.BaseTestCase, ListenerSetupMixin):
|
|||||||
|
|
||||||
self._stop_listener(listener_thread)
|
self._stop_listener(listener_thread)
|
||||||
|
|
||||||
expected = [mock.call({}, 'testpublisher', 'an_event.start', 'test',
|
endpoint.info.assert_has_calls([
|
||||||
{'timestamp': mock.ANY, 'message_id': mock.ANY}),
|
mock.call({}, 'testpublisher', 'an_event.start', 'test',
|
||||||
mock.call({}, 'testpublisher', 'an_event.start', 'test',
|
{'timestamp': mock.ANY, 'message_id': mock.ANY}),
|
||||||
{'timestamp': mock.ANY, 'message_id': mock.ANY})]
|
mock.call({}, 'testpublisher', 'an_event.start', 'test',
|
||||||
self.assertEqual(endpoint.info.call_args_list, expected)
|
{'timestamp': mock.ANY, 'message_id': mock.ANY})])
|
||||||
|
|||||||
Reference in New Issue
Block a user