Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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
Esempio n. 7
0
 def test_str(self):
     reader = Mock()
     impl = Mock()
     body = 'test-body'
     message = Message(reader, impl, body)
     self.assertEqual(str(message), body)
Esempio n. 8
0
 def test_body(self):
     reader = Mock()
     impl = Mock()
     body = 'test-body'
     message = Message(reader, impl, body)
     self.assertEqual(message.body, body)