def test_accept(self): reader = Mock() impl = Mock() body = 'test-body' message = Message(reader, impl, body) message.ack() reader.ack.assert_called_with(impl)
def test_reject(self): reader = Mock() impl = Mock() body = 'test-body' message = Message(reader, impl, body) message.reject(True) reader.reject.assert_called_with(impl, True)
def test_init(self): reader = Mock() impl = Mock() body = 'test-body' message = Message(reader, impl, body) self.assertEqual(message._reader, reader) self.assertEqual(message._impl, impl) self.assertEqual(message._body, body)
def get(self, timeout=None): """ Get the next message from the queue. :param timeout: The read timeout in seconds. :type timeout: int :return: The next message or None. :rtype: Message """ try: impl = self.receiver.receive(timeout or NO_DELAY) return Message(self, impl, impl.body) except Timeout: pass
def test_str(self): reader = Mock() impl = Mock() body = 'test-body' message = Message(reader, impl, body) self.assertEqual(str(message), body)
def test_body(self): reader = Mock() impl = Mock() body = 'test-body' message = Message(reader, impl, body) self.assertEqual(message.body, body)