def test_call(self, _connection, message, uuid): url = 'url-test' name = model.CREATE arguments = {'a': 1} uuid.return_value = '5138' connection = Mock() _connection.return_value = connection sender = Mock() sender.close.side_effect = ValueError receiver = Mock() receiver.close.side_effect = ValueError connection.receiver.return_value = receiver connection.sender.return_value = sender # test method = Method(url, name, arguments) method.send = Mock() method.on_reply = Mock() method() # validation _connection.assert_called_once_with(url) connection.open.assert_called_once_with() connection.sender.assert_called_once_with(model.ADDRESS) connection.receiver.assert_called_once_with(model.ADDRESS, dynamic=True) message.assert_called_once_with( body=method.body, reply_to=receiver.remote_source.address, properties=method.properties, correlation_id=str(uuid.return_value), subject=model.SUBJECT) method.send.assert_called_once_with(message.return_value) method.on_reply.assert_called_once_with(receiver.receive.return_value) sender.close.assert_called_once_with() receiver.close.assert_called_once_with()
def test_call(self, _connection, message, uuid): url = "url-test" name = model.CREATE arguments = {"a": 1} uuid.return_value = "5138" connection = Mock() _connection.return_value = connection sender = Mock() sender.close.side_effect = ValueError receiver = Mock() receiver.close.side_effect = ValueError connection.receiver.return_value = receiver connection.sender.return_value = sender # test method = Method(url, name, arguments) method.send = Mock() method.on_reply = Mock() method() # validation _connection.assert_called_once_with(url) connection.open.assert_called_once_with() connection.sender.assert_called_once_with(model.ADDRESS) connection.receiver.assert_called_once_with(model.ADDRESS, dynamic=True) message.assert_called_once_with( body=method.body, reply_to=receiver.remote_source.address, properties=method.properties, correlation_id=str(uuid.return_value), subject=model.SUBJECT, ) method.send.assert_called_once_with(message.return_value) method.on_reply.assert_called_once_with(receiver.receive.return_value) sender.close.assert_called_once_with() receiver.close.assert_called_once_with()
def test_send(self): request = Mock() method = Method('', '', {}) method.sender = Mock() method.send(request) method.sender.send.assert_called_with(request)
def test_send(self): request = Mock() method = Method("", "", {}) method.sender = Mock() method.send(request) method.sender.send.assert_called_with(request)