Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def test_channel_closed(amqp_connection):
for i in range(10):
channel = await amqp_connection.channel()
with pytest.raises(aiormq.exceptions.ChannelNotFoundEntity):
await channel.basic_consume("foo", lambda x: None)
channel = await amqp_connection.channel()
with pytest.raises(aiormq.exceptions.ChannelNotFoundEntity):
await channel.queue_declare(
"foo_%s" % i, auto_delete=True, passive=True
)
await amqp_connection.close()
def __exception_by_code(frame: spec.Channel.Close): # pragma: nocover
if frame.reply_code == 403:
return exc.ChannelAccessRefused(frame.reply_text)
elif frame.reply_code == 404:
return exc.ChannelNotFoundEntity(frame.reply_text)
elif frame.reply_code == 405:
return exc.ChannelLockedResource(frame.reply_text)
elif frame.reply_code == 406:
return exc.ChannelPreconditionFailed(frame.reply_text)
else:
return exc.ChannelClosed(frame.reply_code, frame.reply_text)