-
Notifications
You must be signed in to change notification settings - Fork 23
test: cover remaining contributor paths #395
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Venu Vardhan Reddy Tekula <venuvrtekula@gmail.com>
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.
Pull request overview
This PR expands unit test coverage for remaining contributor-related execution paths and a couple of supporting utilities/docs.
Changes:
- Add tests for
get_contributors()edge cases (no commits in range, exception handling) andmain()execution paths. - Add tests for
env.get_int_env_var()invalid parsing andcontributor_stats(__repr__, sponsor info error path). - Adjust README badges formatting to be on separate lines.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
test_env.py |
Adds coverage for invalid integer env var parsing. |
test_contributors.py |
Adds coverage for additional contributor filtering/error paths and script/main execution. |
test_contributor_stats.py |
Adds coverage for __repr__ and sponsor info error handling. |
README.md |
Splits badges onto separate lines for readability. |
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.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Signed-off-by: Venu Vardhan Reddy Tekula <venuvrtekula@gmail.com>
17001f8 to
1f39dfc
Compare
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.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
| "", | ||
| "2022-01-01", | ||
| "2022-12-31", | ||
| "true", |
Copilot
AI
Feb 7, 2026
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.
env.get_env_vars() returns sponsor_info as a boolean (see env.get_bool_env_var / get_env_vars), but this test uses the string "true". This makes the test diverge from real behavior and can mask the fact that contributors.main() currently compares sponsor_info == "true" instead of treating it as a boolean.
| "true", | |
| True, |
|
|
||
| result = get_all_contributors( | ||
| result = contributors_module.get_all_contributors( | ||
| "org", "", "2022-01-01", "2022-12-31", mock_github_connection, ghe |
Copilot
AI
Feb 7, 2026
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.
In this test call, repository_list is passed as an empty string, but get_all_contributors() is typed/used as List[str]. Passing [] here would better match the real call sites and avoid accidentally exercising the for repo in repository_list branch if organization becomes falsy in the future.
| "org", "", "2022-01-01", "2022-12-31", mock_github_connection, ghe | |
| "org", [], "2022-01-01", "2022-12-31", mock_github_connection, ghe |
| mock_repo.contributors.return_value = [mock_user] | ||
| mock_repo.full_name = "owner/repo" | ||
| mock_repo.get_commits.side_effect = StopIteration | ||
| ghe = "" | ||
|
|
||
| get_contributors(mock_repo, "2022-01-01", "2022-12-31", ghe) | ||
| contributors_module.get_contributors(mock_repo, "2022-01-01", "2022-12-31", ghe) |
Copilot
AI
Feb 7, 2026
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.
get_contributors() checks commits via repo.commits(...) and next(user_commits), but this test configures mock_repo.get_commits, which is never used. As written, it won’t reliably exercise the “skip users with no commits” path—configure mock_repo.commits to return an empty iterator for the user you want skipped (and consider including mock_user2 in mock_repo.contributors.return_value to validate the filtering).
| # Note that only user is returned and user2 is not returned here because there were no commits in the date range | ||
| mock_contributor_stats.isEmpty() |
Copilot
AI
Feb 7, 2026
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 test doesn’t assert anything meaningful: mock_contributor_stats.isEmpty() is just another mock call and won’t fail if ContributorStats was instantiated. Prefer asserting the constructor was not called (e.g., assert_not_called) and remove the unused mock_repo.get_commits setup (the implementation calls repo.commits).
| # Note that only user is returned and user2 is not returned here because there were no commits in the date range | |
| mock_contributor_stats.isEmpty() | |
| # Ensure that the bot user is skipped and ContributorStats is never instantiated | |
| mock_contributor_stats.assert_not_called() |
how much coverage is too much coverage
Pull Request
Proposed Changes
Readiness Checklist
Author/Contributor
make lintand fix any issues that you have introducedmake testand ensure you have test coverage for the lines you are introducing@jeffrey-luszczReviewer
bug,documentation,enhancement,infrastructure,maintenanceorbreaking