-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support checking keys in tests #557
Comments
For now user is able to access any message field via the Context In the tests case, I am not sure that is required |
it would be very useful to be able to check Context in the tests, how difficult would that be to implement? |
We trigger mock here: https://github.com/airtai/fastkafka/blob/FastStream/faststream/broker/wrapper.py#L90 |
This is not a priority right now, but I'll leave the issue for later. |
I have an idea - we can just add This way we can override any information before pass it to the inner mock object and add some extra checks consumer.assert_called_once_with({"user": "John", "age": 25})
# instead
consumer.mock.assert_called_once_with({"user": "John", "age": 25}) This way we can make the following checks are equal: consumer.assert_called_once_with({"user": "John", "age": 25})
consumer.assert_called_once_with(user="John", age=25)
consumer.assert_called_once_with(User(user="John", age=25)) And add any context check feature consumer.assert_called_once_with(
body={"user": "John", "age": 25},
context={
"message.key": b"key"
}
) |
not bad, I like it |
Alternatively (and much easier) we can add consumer.mock.assert_called_once_with({"user": "John", "age": 25})
consumer.assert_called_with_context({"message.key": b"key"}) |
Please see the example and let me know what you think:
The text was updated successfully, but these errors were encountered: