Skip to content

Commit

Permalink
test: Fix test failing due to common topic on public broker
Browse files Browse the repository at this point in the history
  • Loading branch information
empicano committed Dec 26, 2023
1 parent 0ac878e commit 34f16f4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,16 @@ async def test_client_use_connect_disconnect_multiple_message() -> None:
custom_client = Client(HOSTNAME)
publish_client = Client(HOSTNAME)

topic_a = TOPIC_HEADER + "task/a"
topic_b = TOPIC_HEADER + "task/b"

await custom_client.connect()
await publish_client.connect()

async def task_a_customer(
task_status: TaskStatus[None] = TASK_STATUS_IGNORED,
) -> None:
await custom_client.subscribe("a/b/c")
await custom_client.subscribe(topic_a)
async with custom_client.messages() as messages:
task_status.started()
async for message in messages:
Expand All @@ -491,7 +494,7 @@ async def task_b_customer(
task_status: TaskStatus[None] = TASK_STATUS_IGNORED,
) -> None:
num = 0
await custom_client.subscribe("qwer")
await custom_client.subscribe(topic_b)
async with custom_client.messages() as messages:
task_status.started()
async for message in messages:
Expand All @@ -506,8 +509,8 @@ async def task_publisher(topic: str, payload: PayloadType) -> None:
async with anyio.create_task_group() as tg:
await tg.start(task_a_customer)
await tg.start(task_b_customer)
tg.start_soon(task_publisher, "a/b/c", "task_a")
tg.start_soon(task_publisher, "qwer", "task_b")
tg.start_soon(task_publisher, topic_a, "task_a")
tg.start_soon(task_publisher, topic_b, "task_b")

await custom_client.disconnect()
await publish_client.disconnect()
Expand Down

0 comments on commit 34f16f4

Please sign in to comment.