def test_external_bus_forwards_addressed_messages_to_send_handler(): message = create_some_message() send_handler = Mock() bus = ExternalBus(send_handler) bus.send(message, 'some_node') send_handler.assert_called_once_with(message, 'some_node')
def test_external_bus_queues_sent_messages_sequentially(): messages = [(create_some_message(), choice(['some_node', 'other_node', None])) for _ in range(100)] send_handler = Mock() bus = ExternalBus(send_handler) for message, dst in messages: bus.send(message, dst) assert send_handler.mock_calls == [call(msg, dst) for msg, dst in messages]