How do I test batch processing using the TestBroker #2561
Answered
by
DLukeNelson
DLukeNelson
asked this question in
Q&A
-
|
I have a subscriber set up using # tests.py
# Attempt 1:
await test_broker.publish(msg1, topic=MY_TOPIC)
await test_broker.publish(msg2, topic=MY_TOPIC)
# Consumer was invoked twice, each time with a list[Message] of length 1
# Attempt 2:
await test_broker.publish([msg1, msg2], topic=MY_TOPIC)
# Consumer was invoked once, with a list[list[Message]]How can my tests correctly publish multiple messages to prove my batch handling works? |
Beta Was this translation helpful? Give feedback.
Answered by
DLukeNelson
Oct 9, 2025
Replies: 1 comment
-
|
Almost immediately after posting this question, I had a realization: "Surely this case was tested somewhere within faststream." # Attempt 3:
await test_broker.publish_batch(msg1, msg2, topic=MY_TOPIC)
# Works as expected, consumer was invoked once with a list[Message] of length 2 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Lancetnik
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Almost immediately after posting this question, I had a realization: "Surely this case was tested somewhere within faststream."
So I searched within the faststream tests and came across: