diff --git a/tests_integration/test_barterdude.py b/tests_integration/test_barterdude.py index b44cf68..d5b63e2 100644 --- a/tests_integration/test_barterdude.py +++ b/tests_integration/test_barterdude.py @@ -1,7 +1,7 @@ import asyncio import os from asyncio import Event -from random import choices, random +from random import choices from string import ascii_uppercase import aiohttp @@ -19,10 +19,9 @@ class TestBarterDude(IsolatedAsyncioTestCase): async def asyncSetUp(self): - suffix = str(int(random()*10000)) - self.input_queue = f"test_{suffix}" + self.input_queue = "test_input" self.output_exchange = "test_exchange" - self.output_queue = f"test_output_{suffix}" + self.output_queue = "test_output" self.rabbitmq_host = os.environ.get("RABBITMQ_HOST", "127.0.0.1") self.barterdude_host = os.environ.get("BARTERDUDE_HOST", "127.0.0.1") @@ -35,6 +34,9 @@ async def asyncSetUp(self): ) self.queue_manager = self.connection["/"] await self.queue_manager.connection._connect() + + await self.clear() + await self.queue_manager.connection.channel.queue_declare( self.input_queue ) @@ -59,6 +61,10 @@ async def asyncSetUp(self): async def asyncTearDown(self): await self.app.shutdown() + await self.clear() + await self.queue_manager.connection.close() + + async def clear(self): await self.queue_manager.connection.channel.queue_delete( self.input_queue ) @@ -68,7 +74,6 @@ async def asyncTearDown(self): await self.queue_manager.connection.channel.exchange_delete( self.output_exchange ) - await self.queue_manager.connection.close() async def test_obtains_healthcheck(self): monitor = Monitor(Healthcheck(self.app)) diff --git a/tests_integration/test_rabbitmq_integration.py b/tests_integration/test_rabbitmq_integration.py index 128bfe7..e5922ec 100644 --- a/tests_integration/test_rabbitmq_integration.py +++ b/tests_integration/test_rabbitmq_integration.py @@ -1,7 +1,7 @@ import asyncio import os from asyncio import Event -from random import choices, random +from random import choices from string import ascii_uppercase from unittest import IsolatedAsyncioTestCase @@ -18,10 +18,9 @@ class RabbitMQConsumerTest(IsolatedAsyncioTestCase): async def asyncSetUp(self): - suffix = str(int(random()*10000)) - self.input_queue = f"test_{suffix}" + self.input_queue = "test_input" self.output_exchange = "test_exchange" - self.output_queue = f"test_output_{suffix}" + self.output_queue = "test_output" self.rabbitmq_host = os.environ.get("RABBITMQ_HOST", "127.0.0.1") self.barterdude_host = os.environ.get("BARTERDUDE_HOST", "127.0.0.1") @@ -34,6 +33,9 @@ async def asyncSetUp(self): ) self.queue_manager = self.connection["/"] await self.queue_manager.connection._connect() + + await self.clear() + await self.queue_manager.connection.channel.queue_declare( self.input_queue ) @@ -58,6 +60,10 @@ async def asyncSetUp(self): async def asyncTearDown(self): await self.app.shutdown() + await self.clear() + await self.queue_manager.connection.close() + + async def clear(self): await self.queue_manager.connection.channel.queue_delete( self.input_queue ) @@ -67,7 +73,6 @@ async def asyncTearDown(self): await self.queue_manager.connection.channel.exchange_delete( self.output_exchange ) - await self.queue_manager.connection.close() async def send_all_messages(self): futures = []