Skip to content

Commit d0986ab

Browse files
committed
Fixed tests.
Signed-off-by: Pavel Kirilin <win10@list.ru>
1 parent 3dabd3b commit d0986ab

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

tests/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import uuid
32
from typing import List
43

54
import pytest
@@ -23,7 +22,7 @@ def nats_subject() -> str:
2322
2423
:return: random string.
2524
"""
26-
return uuid.uuid4().hex
25+
return "12345"
2726

2827

2928
@pytest.fixture

tests/test_broker.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@ async def test_success_broadcast(nats_urls: List[str], nats_subject: str) -> Non
2626
await broker.startup()
2727
tasks = []
2828
for _ in range(10):
29-
tasks.append(asyncio.wait_for(asyncio.create_task(read_message(broker)), 1))
29+
tasks.append(asyncio.create_task(read_message(broker)))
3030

3131
sent_message = BrokerMessage(
3232
task_id=uuid.uuid4().hex,
3333
task_name="meme",
3434
message=b"some",
3535
labels={},
3636
)
37+
3738
asyncio.create_task(broker.kick(sent_message))
38-
for received_message in await asyncio.gather(*tasks):
39+
40+
for received_message in await asyncio.wait_for(asyncio.gather(*tasks), timeout=1):
3941
assert received_message == sent_message.message
4042

4143

@@ -45,7 +47,7 @@ async def test_success_queued(nats_urls: List[str], nats_subject: str) -> None:
4547
broker = NatsBroker(servers=nats_urls, subject=nats_subject, queue=uuid.uuid4().hex)
4648
await broker.startup()
4749
reading_task = asyncio.create_task(
48-
asyncio.wait_for(read_message(broker), timeout=1),
50+
read_message(broker),
4951
)
5052

5153
sent_message = BrokerMessage(
@@ -55,4 +57,4 @@ async def test_success_queued(nats_urls: List[str], nats_subject: str) -> None:
5557
labels={},
5658
)
5759
asyncio.create_task(broker.kick(sent_message))
58-
assert await reading_task == sent_message.message
60+
assert await asyncio.wait_for(reading_task, timeout=1) == sent_message.message

0 commit comments

Comments
 (0)