def test_call(self, message, uuid): url = 'url-test' name = model.CREATE arguments = {'a': 1} # test method = Method(url, name, arguments) method.reply_to = '234' method.open = Mock() method.close = Mock() method.session = Mock() method.sender = Mock() method.receiver = Mock() method.on_reply = Mock() method() # validation method.open.assert_called_once_with() message.assert_called_once_with( content=method.content, reply_to=method.reply_to, properties=method.properties, correlation_id=str(uuid.return_value).encode(), subject=model.SUBJECT ) method.session.acknowledge.assert_called_once_with() method.sender.send.assert_called_once_with(message.return_value) method.on_reply.assert_called_once_with(method.receiver.fetch.return_value) method.close.assert_called_once_with()
def test_close(self): connection = Mock() session = Mock(connection=connection) sender = Mock() receiver = Mock() method = Method('', '', {}) method.connection = connection method.session = session method.sender = sender method.receiver = receiver # test method.close() # validation receiver.close.assert_called_once_with() sender.close.assert_called_once_with() session.close.assert_called_once_with() self.assertFalse(connection.close.called)
def test_close(self): connection = Mock() session = Mock(connection=connection) sender = Mock() receiver = Mock() method = Method('', '', {}) method.connection = connection method.session = session method.sender = sender method.receiver = receiver # test method.close() # validation receiver.close.assert_called_once_with() sender.close.assert_called_once_with() session.close.assert_called_once_with() self.assertFalse(connection.close.called)