Skip to content

Commit

Permalink
Clearing queue instead of randomize the name
Browse files Browse the repository at this point in the history
  • Loading branch information
timotta committed Apr 17, 2023
1 parent 17f071c commit ab2c74c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
15 changes: 10 additions & 5 deletions tests_integration/test_barterdude.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")

Expand All @@ -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
)
Expand All @@ -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
)
Expand All @@ -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))
Expand Down
15 changes: 10 additions & 5 deletions tests_integration/test_rabbitmq_integration.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")

Expand All @@ -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
)
Expand All @@ -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
)
Expand All @@ -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 = []
Expand Down

0 comments on commit ab2c74c

Please sign in to comment.