Skip to content

Commit

Permalink
tester: Process message contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Gascon-Lefebvre authored and isra17 committed Nov 23, 2023
1 parent 8f88600 commit 0fa956e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
9 changes: 5 additions & 4 deletions src/saturn_engine/utils/tester/inventory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ def run_saturn_inventory(
async def run_inventory() -> None:
count = 0
async for item in inventory.iterate(after=after):
items.append(asdict(item.as_topic_message()))
count = count + 1
if limit and count >= limit:
break
async with item:
items.append(asdict(item.as_topic_message()))
count = count + 1
if limit and count >= limit:
break

asyncio.run(run_inventory())

Expand Down
19 changes: 8 additions & 11 deletions src/saturn_engine/utils/tester/topic_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import AsyncContextManager
from typing import Optional

import asyncio
Expand Down Expand Up @@ -33,17 +32,15 @@ async def run_topic() -> None:
count = 0
skipped = 0
async for message in topic.run():
if skip is not None and skipped < skip:
skipped += 1
continue
async with message:
if skip is not None and skipped < skip:
skipped += 1
continue

if isinstance(message, AsyncContextManager):
message = await message.__aenter__()

messages.append(asdict(message))
count = count + 1
if limit and count >= limit:
break
messages.append(asdict(message))
count = count + 1
if limit and count >= limit:
break

asyncio.run(run_topic())

Expand Down

0 comments on commit 0fa956e

Please sign in to comment.