Skip to content

Commit

Permalink
Merge pull request #65 from kpn/fix/producer-test-client
Browse files Browse the repository at this point in the history
fix: use partition 1 as default partition when producing with test cl…
  • Loading branch information
woile authored Oct 6, 2022
2 parents ec74eeb + 71797bc commit 68593bb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion kstreams/test_utils/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def send(
async def fut():
return RecordMetadata(
topic=topic_name,
partition=1,
partition=partition,
timestamp=timestamp_ms,
offset=total_messages,
)
Expand Down
2 changes: 1 addition & 1 deletion kstreams/test_utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def send(
topic: str,
value: Any = None,
key: Optional[Any] = None,
partition: Optional[int] = None,
partition: int = 1,
timestamp_ms: Optional[int] = None,
headers: Optional[Headers] = None,
serializer: Optional[Serializer] = None,
Expand Down
6 changes: 5 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async def test_send_event_with_test_client(stream_engine: StreamEngine):
)
current_offset = metadata.offset
assert metadata.topic == topic
assert metadata.partition == 1

# send another event and check that the offset was incremented
metadata = await client.send(
Expand Down Expand Up @@ -109,7 +110,10 @@ async def my_stream(stream: Stream):
client = TestStreamClient(stream_engine)
async with client:
for _ in range(0, total_events):
await client.send(topic_name, partition=partition, value=value, key=key)
record_metadata = await client.send(
topic_name, partition=partition, value=value, key=key
)
assert record_metadata.partition == partition

# check that everything was commited
stream = stream_engine.get_stream(name)
Expand Down

0 comments on commit 68593bb

Please sign in to comment.