Ejemplo n.º 1
0
 def test_accept(self):
     reader = Mock()
     impl = Mock()
     body = 'test-body'
     message = Message(reader, impl, body)
     message.ack()
     reader.ack.assert_called_with(impl)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 def test_accept(self):
     reader = Mock()
     impl = Mock()
     body = 'test-body'
     message = Message(reader, impl, body)
     message.ack()
     reader.ack.assert_called_with(impl)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 def test_str(self):
     reader = Mock()
     impl = Mock()
     body = 'test-body'
     message = Message(reader, impl, body)
     self.assertEqual(str(message), body)
Ejemplo n.º 8
0
 def test_body(self):
     reader = Mock()
     impl = Mock()
     body = 'test-body'
     message = Message(reader, impl, body)
     self.assertEqual(message.body, body)