async def test_broker_rebind_fail_limit(): broker = AMQPBroker('amqp://localhost') broker.bind = AsyncMock() broker._bind_attempts['test_queue'] = 4 try: assert await broker.rebind('test_queue') is False except AttributeError: # for travis pass broker.bind.assert_not_called()
async def test_broker_rebind_ok(): broker = AMQPBroker('amqp://localhost') broker._bind_attempts['test_queue'] = 0 broker.bind = AsyncMock() assert await broker.rebind('test_queue') broker.bind.assert_called_once_with('test_queue')
async def test_broker_rebind_fail_oserror(): broker = AMQPBroker('amqp://localhost') broker.bind = AsyncMock(side_effect=OSError()) broker._bind_attempts['test_queue'] = 0 assert not await broker.rebind('test_queue')
async def test_broker_rebind_fail_close_channel(): broker = AMQPBroker('amqp://localhost') broker.bind = AsyncMock(side_effect=aioamqp.ChannelClosed()) broker._bind_attempts['test_queue'] = 0 assert not await broker.rebind('test_queue')
async def test_broker_rebind_fail_limit(): broker = AMQPBroker('amqp://localhost') broker.bind = AsyncMock() broker._bind_attempts['test_queue'] = 4 assert await broker.rebind('test_queue') is None broker.bind.assert_not_called()