async def test_broker_rollback_many_attempts_ok(): queue = Queue(name='test_queue') broker = AIORedisBroker('redis://localhost') broker.send = AsyncMock() broker._rollbacks[str(hash(queue.name)) + str(hash('{}'))] = 4 await broker.rollback(queue.name, '{}') broker.send.assert_not_called()
async def test_broker_handling_sync_rollback_ok(): queue = Queue(name='test_queue') consumer = Consumer(agent=None, handler=Mock(side_effect=Exception), queue=queue, timeout=1, options={}) broker = AIORedisBroker('redis://localhost') broker.send = AsyncMock() broker._bindings[queue.name] = consumer await broker._handler(queue.name, '{}') consumer.handler.assert_called_once() await asyncio.sleep(.01) broker.send.assert_called_once_with(queue.name, '{}')