-
Notifications
You must be signed in to change notification settings - Fork 10
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
Provide a generic load_poses.from_file() function #107 #110
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #110 +/- ##
=======================================
Coverage 99.12% 99.13%
=======================================
Files 8 8
Lines 458 461 +3
=======================================
+ Hits 454 457 +3
Misses 4 4 ☔ 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.
Thanks for this @DhruvSkyy!
I've left a few comments, but apart from these, let's discuss testing.
When it comes to testing a function like from_file
that delegates its operations to other functions (from_dlc_file
, from_sleap_file
, from_lp_file
), which are already thoroughly tested, our primary goal should be to ensure that the delegation logic is correct without necessarily re-testing the functionality of the underlying functions in depth.
I would probably add one more function to the TestLoadPoses
class, doing sth akin to the following:
@pytest.mark.parametrize(
"source_software",
["SLEAP", "DeepLabCut", "LightningPose", "Unknown"]
)
@pytest.mark.parametrize("fps", [None, 30, 60.0])
def test_from_file_delegates_correctly(self, source_software, fps):
"""Test that the from_file() function delegates to the correct
loader function according to the source_software."""
software_to_loader = {
"SLEAP": "movement.io.load_poses.from_sleap_file",
"DeepLabCut": "movement.io.load_poses.from_dlc_file",
"LightningPose": "movement.io.load_poses.from_lp_file",
}
if source_software == "Unknown":
with pytest.raises(ValueError):
load_poses.from_file("some_file", source_software)
else:
with patch(software_to_loader[source_software]) as mock_loader:
load_poses.from_file("some_file", source_software, fps)
mock_loader.assert_called_with("some_file", fps)
The above test just ensures that the correct underlying loader is called with the right parameters passed to it. We do not actually want to call the underlying functions (because we have tested that already many times), that's why I've used mocking (pretend that we are calling them).
FYI, you would have to from unittest.mock import patch
and you would also need to handle the case of unknown software in the implementation of from_file
(see one of my comments).
* Bump action versions in upload_pypi workflow step * reuse the upload_pypi action instead of custom steps
Quality Gate passedIssues Measures |
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 implementing the suggestions @DhruvSkyy !!
I've updated the documentation accordingly. I'll approve and merge this PR now 🎉
Description
What is this PR
Creates a generic function from_file() which is identical to:
Can be called by specifying source software,
References
Closes #98
Checklist: