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

Unit tests upgrade. #145

Merged
merged 7 commits into from
Dec 9, 2024
Merged

Unit tests upgrade. #145

merged 7 commits into from
Dec 9, 2024

Conversation

kkeroo
Copy link
Collaborator

@kkeroo kkeroo commented Dec 4, 2024

This PR refactors creators unit tests and updates the unit tests with the tests for message types. Unittests folder is now structured like:

unittests
-- test_creators
-- test_messages

I cleaned the creators tests and did some changes so they follow the creator functions. Newly added unittests for message types extends our CI testing.

@kkeroo kkeroo added the tests Changes affecting tests label Dec 4, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.94%. Comparing base (37a2d92) to head (2964afc).
Report is 20 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
+ Coverage   33.40%   35.94%   +2.54%     
==========================================
  Files          68       69       +1     
  Lines        3739     3836      +97     
==========================================
+ Hits         1249     1379     +130     
+ Misses       2490     2457      -33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@klemen1999 klemen1999 left a comment

Choose a reason for hiding this comment

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

Generally LGTM, @jkbmrz could you take a look as well

Copy link
Collaborator

@jkbmrz jkbmrz left a comment

Choose a reason for hiding this comment

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

Generally LGTM! Adding some non-blocking comments and suggesting a small stylistic change:
We could increase readability of the tests by defining the correct argument values as variables instead of re-defining them anew for each test function. For example, we could change:

def test_invalid_keypoints_type():
    with pytest.raises(ValueError):
        create_detection_message(
            np.array([[0.5, 0.5, 0.2, 0.2]]), np.array([0.9]), keypoints=[[[0.1, 0.1]]]
        )

to:

BBOXES = np.array([[0.5, 0.5, 0.2, 0.2]])
SCORES = np.array([0.9])

def test_invalid_keypoints_type():
    with pytest.raises(ValueError):
        create_detection_message(
            BBOXES, SCORES, keypoints=[[[0.1, 0.1]]]
        )

and re-use the defined variables throughout the tests.This would increase the readability as the the reader could better focus on the tested values (and ignore the correct ones).

):
create_image_message(img)

def test_valid_chw_bgr():
Copy link
Collaborator

@jkbmrz jkbmrz Dec 6, 2024

Choose a reason for hiding this comment

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

Same here and above, I think we could simplify these tests and have the assert checks in one test function only.

@kkeroo
Copy link
Collaborator Author

kkeroo commented Dec 9, 2024

@jkbmrz thanks for detailed review. I fixed your suggestions and added global variables so we dont define vars inside each test.

@kkeroo kkeroo requested a review from jkbmrz December 9, 2024 10:25
@kkeroo kkeroo merged commit f11ad94 into main Dec 9, 2024
10 checks passed
@kkeroo kkeroo deleted the tests/unittests branch December 9, 2024 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Changes affecting tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants