-
Notifications
You must be signed in to change notification settings - Fork 0
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
Increase test coverage #78
Conversation
WalkthroughThe latest update enhances the robustness of the video loading process in Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration 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.
Actionable comments posted: 3
Out of diff range and nitpick comments (2)
tests/test_series.py (2)
Line range hint
2-2
: Remove the unused import ofnumpy
.- import numpy as np
This import is unused and should be removed to clean up the code.
Line range hint
142-142
: Rename the redefinedtest_series_name
function to avoid confusion.- def test_series_name(dummy_series): + def test_series_name_from_dummy(dummy_series):This change avoids the redefinition of
test_series_name
, which is already defined earlier in the file.
tests/test_series.py
Outdated
def test_primary_prediction_not_found(tmp_path): | ||
dummy_video_path = tmp_path / "dummy_video.mp4" | ||
dummy_video_path.write_text("This is a dummy video file.") | ||
|
||
# Create a dummy Series instance with a non-existent primary prediction file | ||
output = io.StringIO() | ||
with redirect_stdout(output): | ||
Series.load(h5_path=str(dummy_video_path), primary_name="nonexistent") | ||
|
||
# format file path string for assert statement | ||
path_obj = Path(dummy_video_path) | ||
parent_dir = path_obj.parent | ||
filename_without_extension = path_obj.stem | ||
new_file_path = parent_dir / filename_without_extension | ||
|
||
assert output.getvalue() == f"Primary prediction file not found: {new_file_path}.nonexistent.predictions.slp\n" |
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.
Simplify the path manipulation in the error message construction.
- path_obj = Path(dummy_video_path)
- parent_dir = path_obj.parent
- filename_without_extension = path_obj.stem
- new_file_path = parent_dir / filename_without_extension
+ new_file_path = Path(dummy_video_path).with_suffix('')
This change uses the with_suffix('')
method to remove the extension from the path, simplifying the code and achieving the same result.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
def test_primary_prediction_not_found(tmp_path): | |
dummy_video_path = tmp_path / "dummy_video.mp4" | |
dummy_video_path.write_text("This is a dummy video file.") | |
# Create a dummy Series instance with a non-existent primary prediction file | |
output = io.StringIO() | |
with redirect_stdout(output): | |
Series.load(h5_path=str(dummy_video_path), primary_name="nonexistent") | |
# format file path string for assert statement | |
path_obj = Path(dummy_video_path) | |
parent_dir = path_obj.parent | |
filename_without_extension = path_obj.stem | |
new_file_path = parent_dir / filename_without_extension | |
assert output.getvalue() == f"Primary prediction file not found: {new_file_path}.nonexistent.predictions.slp\n" | |
def test_primary_prediction_not_found(tmp_path): | |
dummy_video_path = tmp_path / "dummy_video.mp4" | |
dummy_video_path.write_text("This is a dummy video file.") | |
# Create a dummy Series instance with a non-existent primary prediction file | |
output = io.StringIO() | |
with redirect_stdout(output): | |
Series.load(h5_path=str(dummy_video_path), primary_name="nonexistent") | |
# format file path string for assert statement | |
new_file_path = Path(dummy_video_path).with_suffix('') | |
assert output.getvalue() == f"Primary prediction file not found: {new_file_path}.nonexistent.predictions.slp\n" |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #78 +/- ##
==========================================
+ Coverage 74.62% 75.18% +0.55%
==========================================
Files 13 13
Lines 1344 1346 +2
==========================================
+ Hits 1003 1012 +9
+ Misses 341 334 -7 ☔ 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.
Actionable comments posted: 0
Out of diff range and nitpick comments (2)
tests/test_series.py (2)
Line range hint
2-2
: Remove unused import to clean up the code.- import numpy as np
Line range hint
159-159
: Rename the function to avoid redefinition and potential test execution issues.- def test_series_name(series_instance): + def test_series_name_from_instance(series_instance):
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.
Actionable comments posted: 0
Out of diff range and nitpick comments (2)
tests/test_series.py (2)
Line range hint
2-2
: Remove unused import to clean up the code.- import numpy as np
Line range hint
150-150
: Rename the function to avoid redefinition and potential test suite issues.- def test_series_name(series_instance): + def test_series_name_from_instance(series_instance):
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/test_series.py (3 hunks)
Additional Context Used
Ruff (2)
tests/test_series.py (2)
2-2:
numpy
imported but unused
150-150: Redefinition of unused
test_series_name
from line 131
Additional comments not posted (5)
tests/test_series.py (5)
62-77
: LGTM! Good use of fixtures and stdout redirection for testing error handling.
80-95
: LGTM! Consistent approach in testing different prediction types.
98-113
: LGTM! Consistent and clear testing methodology across different prediction types.
116-128
: LGTM! Properly tests the error handling for video loading.
159-167
: LGTM! Effective testing of error handling for CSV path issues.
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.
Actionable comments posted: 0
Out of diff range and nitpick comments (5)
tests/test_series.py (5)
Line range hint
2-2
: Remove unused import to clean up the code.- import numpy as np
62-77
: Ensure consistent error message formatting across similar test functions.Consider using a helper function to format the error message to ensure consistency and reduce duplication.
80-95
: Ensure consistent error message formatting across similar test functions.Consider using a helper function to format the error message to ensure consistency and reduce duplication.
98-113
: Ensure consistent error message formatting across similar test functions.Consider using a helper function to format the error message to ensure consistency and reduce duplication.
Line range hint
150-150
: Remove the redefinition of the functiontest_series_name
to avoid confusion and potential errors.- def test_series_name(series_instance): - assert series_instance.series_name == "dummy"
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/test_series.py (3 hunks)
Additional Context Used
Ruff (2)
tests/test_series.py (2)
2-2:
numpy
imported but unused
150-150: Redefinition of unused
test_series_name
from line 131
Additional comments not posted (2)
tests/test_series.py (2)
7-8
: Import statements forredirect_stdout
andio
are correctly added to support the new test functionalities.
116-128
: Correctly handles the scenario where an invalid video file path is provided.
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.
Great! Just always use Path
from pathlib to make file paths accessible across platforms. It should pass the tests after that.
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.
Actionable comments posted: 0
Out of diff range and nitpick comments (2)
tests/test_series.py (2)
Line range hint
2-2
: Remove unused import to clean up the code.- import numpy as np
Line range hint
150-150
: Avoid redefining the functiontest_series_name
which was previously defined at line 131. Consider renaming one of the functions or consolidating their logic if applicable.- def test_series_name(series_instance): + def test_series_name_from_instance(series_instance):
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/test_series.py (3 hunks)
Additional Context Used
Ruff (2)
tests/test_series.py (2)
2-2:
numpy
imported but unused
150-150: Redefinition of unused
test_series_name
from line 131
Additional comments not posted (6)
tests/test_series.py (6)
7-8
: The import statements forredirect_stdout
andio
are correctly added to support the new test functionalities.
62-77
: The test functiontest_primary_prediction_not_found
correctly simulates the scenario where the primary prediction file is not found. The use ofredirect_stdout
to capture the output for assertion is appropriate.
80-95
: The test functiontest_lateral_prediction_not_found
correctly simulates the scenario where the lateral prediction file is not found. The structure and logic are consistent with other similar test functions.
98-113
: The test functiontest_crown_prediction_not_found
correctly simulates the scenario where the crown prediction file is not found. This maintains consistency in testing various label types.
116-128
: The test functiontest_video_loading_error
effectively checks for errors during video file loading, ensuring that the error handling in theSeries.load
method is robust.
159-167
: The test functiontest_expected_count_error
correctly simulates the scenario where the CSV path is invalid. The use ofredirect_stdout
to capture and assert the error message is consistent with other tests.
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.
Actionable comments posted: 0
Out of diff range and nitpick comments (2)
tests/test_series.py (2)
Line range hint
2-2
: Remove unused import to clean up the code.- import numpy as np
Line range hint
150-150
: Remove or rename this function to avoid redefinition and potential test suite issues.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/test_series.py (3 hunks)
Additional Context Used
Ruff (2)
tests/test_series.py (2)
2-2:
numpy
imported but unused
150-150: Redefinition of unused
test_series_name
from line 131
Additional comments not posted (10)
tests/test_series.py (10)
Line range hint
10-13
: This fixture is correctly implemented.
Line range hint
17-20
: This fixture is correctly implemented.
Line range hint
28-32
: This fixture is correctly implemented.
Line range hint
36-44
: This fixture is correctly implemented.
Line range hint
48-54
: This fixture is correctly implemented.
62-77
: This test function is correctly implemented and checks the error handling effectively.
80-95
: This test function is correctly implemented and checks the error handling effectively.
98-113
: This test function is correctly implemented and checks the error handling effectively.
116-128
: This test function is correctly implemented and checks the error handling effectively.
159-167
: This test function is correctly implemented and checks the error handling effectively.
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.
Actionable comments posted: 0
Out of diff range and nitpick comments (2)
tests/test_series.py (2)
Line range hint
2-2
: Remove unused import to clean up the code.- import numpy as np
Line range hint
151-151
: Redefinition of functiontest_series_name
could lead to confusion and test failures.Consider renaming one of the functions to avoid conflicts.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/test_series.py (3 hunks)
Additional Context Used
Ruff (2)
tests/test_series.py (2)
2-2:
numpy
imported but unused
151-151: Redefinition of unused
test_series_name
from line 132
Additional comments not posted (5)
tests/test_series.py (5)
62-78
: The test function for handling non-existent primary prediction files is well-implemented.
81-96
: The test function for handling non-existent lateral prediction files is correctly implemented.
99-114
: The test function for handling non-existent crown prediction files is correctly implemented.
117-129
: The test function for handling video loading errors is correctly implemented.
160-168
: The test function for handling errors related to an invalid CSV path is correctly implemented.
Series
class cannot find a file needed forSeries.load()
Series.load()
Summary by CodeRabbit