async def test_process_success_from_reject_to_requeue(self):
     message = RabbitMQMessage(body={},
                               delivery_tag=10,
                               on_success=Actions.REJECT)
     message.reject(requeue=True)
     await message.process_success(self.queue_mock)
     self.queue_mock.reject.assert_awaited_with(delivery_tag=10,
                                                requeue=True)
     self.queue_mock.ack.assert_not_awaited()
    async def test_process_exception_from_requeue_to_reject(self):
        message = RabbitMQMessage(body={},
                                  delivery_tag=10,
                                  on_exception=Actions.REQUEUE)
        message.reject(requeue=False)

        await message.process_exception(self.queue_mock)
        self.queue_mock.reject.assert_awaited_with(delivery_tag=10,
                                                   requeue=False)
        self.queue_mock.ack.assert_not_awaited()
Esempio n. 3
0
 async def test_process_success_from_reject_to_requeue(self):
     message = RabbitMQMessage(
         delivery_tag=10,
         on_success=Actions.REJECT,
         amqp_message=self.amqp_message,
     )
     message.reject(requeue=True)
     await message.process_success()
     self.amqp_message.reject.assert_awaited_with(requeue=True)
     self.amqp_message.ack.assert_not_awaited()
Esempio n. 4
0
    async def test_process_exception_from_requeue_to_reject(self):
        message = RabbitMQMessage(
            delivery_tag=10,
            on_exception=Actions.REQUEUE,
            amqp_message=self.amqp_message,
        )
        message.reject(requeue=False)

        await message.process_exception()
        self.amqp_message.reject.assert_awaited_with(requeue=False)
        self.amqp_message.ack.assert_not_awaited()
    async def test_process_message_to_be_rejected(self):
        """
        Sempre fazemos reject com requeue.
        """
        expected_body = {"key": "value"}
        message = RabbitMQMessage(body=expected_body, delivery_tag=42)
        message.reject()

        queue_mock = CoroutineMock(ack=CoroutineMock(), reject=CoroutineMock())
        await message.process(queue_mock)
        queue_mock.reject.assert_awaited_once_with(delivery_tag=42, requeue=True)
        self.assertEqual(0, queue_mock.ack.await_count)
 def test_mark_message_to_be_rejected(self):
     message = RabbitMQMessage({}, 10)
     message.reject()
     self.assertFalse(message._do_ack)