Skip to content
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 Aggregation Tests #645

Merged
merged 12 commits into from
Aug 31, 2022
Merged

Refactor Aggregation Tests #645

merged 12 commits into from
Aug 31, 2022

Conversation

kidrahahjo
Copy link
Collaborator

@kidrahahjo kidrahahjo commented Jun 1, 2022

Description

Refactor tests written for aggregates.py

Motivation and Context

Refer to #611

Checklist:

@kidrahahjo kidrahahjo requested review from a team as code owners June 1, 2022 09:26
@kidrahahjo kidrahahjo requested review from tcmoore3 and Tobias-Dwyer and removed request for a team June 1, 2022 09:26
@codecov
Copy link

codecov bot commented Jun 1, 2022

Codecov Report

Merging #645 (9fd79af) into master (b550ffa) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #645   +/-   ##
=======================================
  Coverage   79.84%   79.84%           
=======================================
  Files          33       33           
  Lines        3195     3195           
  Branches      682      682           
=======================================
  Hits         2551     2551           
  Misses        507      507           
  Partials      137      137           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@bdice bdice changed the title Refactor testing heirarchy Refactor testing hierarchy Jun 1, 2022
@b-butler
Copy link
Member

b-butler commented Jun 1, 2022

@kidrahahjo I like the idea of making our test files more modular, but I would caution against using a directory named common, misc, etc. as these names are fairly ambiguous. I think that matching the module structure generally works best. Here where we have one monster file, I think splitting these tests into multiple files is fine.

@kidrahahjo
Copy link
Collaborator Author

@kidrahahjo I like the idea of making our test files more modular, but I would caution against using a directory named common, misc, etc. as these names are fairly ambiguous. I think that matching the module structure generally works best. Here where we have one monster file, I think splitting these tests into multiple files is fine.

Okay! I will make it similar to that of the module.

@kidrahahjo kidrahahjo changed the title Refactor testing hierarchy Refactor Aggregation Tests Jun 1, 2022
@kidrahahjo
Copy link
Collaborator Author

This PR should then do some additional work as well. I think refactoring aggregation tests would be great for the scope of this PR.

Copy link
Collaborator Author

@kidrahahjo kidrahahjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert unrelated change

requirements/requirements-test.txt Outdated Show resolved Hide resolved
requirements/requirements-dev.txt Outdated Show resolved Hide resolved
@kidrahahjo
Copy link
Collaborator Author

Requesting @b-butler to review this, since I've written most of the aggregation tests with him.

@kidrahahjo kidrahahjo requested a review from b-butler June 2, 2022 11:54
Copy link
Member

@b-butler b-butler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments and suggestions to address.

tests/conftest.py Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/test_aggregates.py Outdated Show resolved Hide resolved
Comment on lines 65 to 66
def create_aggregate_store(self, aggregator_instance, project):
return aggregator_instance._create_AggregateStore(project)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just call aggregator_instance._create_AggregatorStore(project) directly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could call it directly, but it makes the code look more clean IMO. Happy to change this if you want

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I'm stating this though is that if I remove this then I'll have to add multiple lines of code for initializing the aggregator_instance first. It might be painful to do that but if the current one is against best practices then I'm happy to change this.
@b-butler what do you suggest?

tests/test_aggregates.py Outdated Show resolved Hide resolved
tests/test_aggregates.py Outdated Show resolved Hide resolved
tests/test_aggregates.py Outdated Show resolved Hide resolved
Comment on lines 303 to 305
assert list(aggregate_instance._aggregator_function(agg_value)) == [
tuple(agg_value)
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert list(aggregate_instance._aggregator_function(agg_value)) == [
tuple(agg_value)
]
assert next(aggregate_instance._aggregator_function(agg_value)) == tuple(agg_value)

Also, this check seems a bit off to me. I get that we just wrap anything passed in a tuple by default, but this isn't really what the default aggregator is for. At the very least we should comment why this check exists.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be choosing the first element here using next because we need to make sure that the output of _aggregator_function is everything grouped into 1.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your thoughts, just testing the aggregator on random input feels off. We also don't need to parameterize this test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, let's remove the parameters but are you suggesting to remove this test instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the parameters, let me know how it looks

tests/test_aggregates.py Outdated Show resolved Hide resolved
Copy link
Member

@tcmoore3 tcmoore3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Approving since addressing Brandon's comments should be sufficient.

@kidrahahjo kidrahahjo changed the base branch from test-refactor/main to master August 10, 2022 20:21
@kidrahahjo kidrahahjo requested a review from b-butler August 10, 2022 20:21
@vyasr
Copy link
Contributor

vyasr commented Aug 29, 2022

@b-butler how does everything here look to you now? It looks like you're pretty deep into the review already and it's probably easier for you to finish than to bring in anyone else, but feel free to ping if it needs another eye.

Copy link
Member

@b-butler b-butler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kidrahahjo
Copy link
Collaborator Author

Merging this as it has two approvals.

@kidrahahjo kidrahahjo merged commit 2b9ad98 into master Aug 31, 2022
@kidrahahjo kidrahahjo deleted the test-refactor/structuring branch August 31, 2022 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants