-
-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
refactor: use pytest fixtures to parameterize tests for lead acid battery model #4723
refactor: use pytest fixtures to parameterize tests for lead acid battery model #4723
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4723 +/- ##
========================================
Coverage 98.70% 98.70%
========================================
Files 304 304
Lines 23452 23452
========================================
Hits 23149 23149
Misses 303 303 ☔ View full report in Codecov by Sentry. |
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.
I haven't gone through the tests in detail, just skimmed them for now – I think this looks wrong because tests for options such as {"current collector": "potential pair", "dimensionality": 1}
that were previously present have been removed, apparently. The tests for the lumped thermal model are not present either (and others). Is this PR ready for review, @Aswinr24, or is it in progress and you're writing more tests? Apologies if it's the latter (and please mark it as a draft if it is!)
@Aswinr24 Thanks for adding fixtures across tests! I suggest covering multiple files per PR so we don't have too many PRs covering single files. While you are working with this file, try to find more tests that can be parameterized using fixtures and cover those in this PR as well. Once you have enough tests, you can mark this for review. Also, make a list of files (for yourself, no need to open any tracking issue) to keep track of the files you went through and the ones that are pending. I'll add my reviews once it's marked as ready. |
Thanks for the feedback @prady0t @agriyakhetarpal ! |
@prady0t @agriyakhetarpal Could You Please Review this. |
tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py
Show resolved
Hide resolved
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 by looking at the changes, I think we can use parametrize fixture here. @Aswinr24 can you maybe look into ways you can parametrize these tests?
Before that please add the class structure back, it would be easier to review with a cleaner diff.
@prady0t Thanks for the review, added back the class structure and tried to use the parameterize fixture wherever feasible. |
It looks good. The tests look clean! The CI failure is unrelated to this PR, as the tests pass locally for me. Maybe we should re-run. @agriyakhetarpal would love your thoughts on these changes. |
@agriyakhetarpal could you please review this submission and check if it is good to go? |
Hi @Aswinr24, thanks for your work! I haven't had time to look at these changes in detail, sorry for the delay on this. I'll try to do so this weekend. |
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.
Thanks for picking this up, @Aswinr24! Sorry for the delay in review. See my comments below -
@pytest.fixture | ||
def loqs_model(): | ||
return pybamm.lead_acid.LOQS() |
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 looks like a redundant refactor (plus pass-by-sharing might meddle with the tests here), so I would suggest initialising the model in each test (just how it is done right now).
tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py
Outdated
Show resolved
Hide resolved
tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py
Outdated
Show resolved
Hide resolved
Could you also resolve the conflicts? Thanks! |
Thanks for the review! |
@Saransh-cpp done with my changes needed and resolving conflicts, waiting to hear if it is good to go ? |
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.
Thanks, @Aswinr24! This looks good to me. I will wait for a review by others before merging this.
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.
Lgtm. Thanks @Aswinr24!
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.
Thanks, @Aswinr24! I have a couple of small suggestions, happy to approve after.
tests/unit/test_models/test_full_battery_models/test_lead_acid/test_full.py
Outdated
Show resolved
Hide resolved
tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py
Outdated
Show resolved
Hide resolved
@agriyakhetarpal Done with my changes! waiting to hear if it is good to go ? |
This is good to go, indeed. Thanks, @Aswinr24! |
Description
Refactored the lead-acid model test cases to use pytest fixtures, reducing code duplication and improving test clarity and maintainability.
Related to #4502
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ pre-commit run
(or$ nox -s pre-commit
) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ python run-tests.py --all
(or$ nox -s tests
)$ python run-tests.py --doctest
(or$ nox -s doctests
)You can run integration tests, unit tests, and doctests together at once, using
$ nox -s quick
.Further checks: