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
Refactor: Events: Clean up tests #10160
Conversation
LocalStack Community integration with Pro 2 files ±0 2 suites ±0 1h 29m 23s ⏱️ - 2m 33s Results for commit 9ce2706. ± Comparison against base commit be903b2. This pull request removes 49 and adds 49 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
93ff37c
to
bfaf207
Compare
e4d061d
to
d5bdfb2
Compare
e823011
to
d802fb7
Compare
311039b
to
56d2c0a
Compare
56d2c0a
to
7ad5476
Compare
use class since InputTransformer tests will also be part of input test file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea 💡
Refactoring tests can by definition not change any behavior, therefore this PR should have the semver label patch
. The label feature also does not apply here.
Given that re-grouping is the main contribution of this PR, it would make sense to write a short docstring description at the top of the new test files to clarify the separation. Examples from Lambda:
"""API-focused tests only. """Testing different runtimes focusing on common functionality that should work across all runtimes (e.g., echo invoke). """Testing different Lambda runtimes focusing on specifics of particular runtimes (e.g., Nodejs ES6 modules).
So many unvalidated tests 😅 We have a mission 📈
|
||
|
||
def sqs_collect_messages( | ||
aws_client, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you remove the typings "SQSClient"
deliberately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I moved it to use the aws_client directly to keep it in line with how we generally call boto clients.
@markers.aws.unknown | ||
def test_put_events_with_values_in_array(self, aws_client, put_events_with_filter_to_sqs): | ||
def test_put_events_with_values_in_array(sef, put_events_with_filter_to_sqs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: self
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in: bf0255f
@@ -1,6 +1,87 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This snapshot file still contains some tests moved into other files. For example: tests/aws/services/events/test_events.py::TestEvents::test_put_rule
. These should be removed. We don't have good tooling for maintaining snapshots during refactorings.
For such refactorings: I typically just delete the snapshot and validations files and re-create all snapshots from scratch.
assert put_response["FailedEntryCount"] == 0 | ||
assert put_response["FailedEntries"] == [] | ||
|
||
def check_stream_status(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea for later: Such waiters seem quite common in our test suite. We could consider adding a re-usable helper or even waiter (Dominik demoed how the boto waiters can be extended).
|
||
message_body = json.loads(messages[0]["Body"]) | ||
assert message_body["time"] == "2022-01-01T00:00:00Z" | ||
|
||
|
||
class TestEventsInputTransformers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good example to think where it belongs to:
- Would input transformers fit into test_events_inputs?
- Different integrations have different transformer behavior?
- Or here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in: 8fa25b3
af485bf
to
b13ca25
Compare
Motivation
The current events tests are all defined in a single file
.../events/test_events.py
, including (except one) the fixtures not imported from...fixtures.py
. This makes it hard to read and add new tests especially grouping them to similar tests.Change
conftest.py
filetests_events_rules.py
tests_events_integrations.py
tests_events_inputs.py
, also separating InputPaths into a separate class to deal with future InputTransformers