Skip to content

Commit 5e52461

Browse files
zkoppertCopilot
andcommitted
test: add return value assertions and fix stale test name
Address PR review feedback: - Add return value assertions to test_get_contributors and test_get_contributors_skip_bot for stricter contract verification - Rename test_get_contributors_skip_users_with_no_commits to test_get_contributors_with_single_commit to match actual behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 545219a commit 5e52461

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

test_contributors.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ def test_get_contributors(self, mock_contributor_stats):
2727
mock_repo.full_name = "owner/repo"
2828
mock_repo.commits.return_value = iter([mock_commit])
2929

30-
contributors_module.get_contributors(mock_repo, "2022-01-01", "2022-12-31", "")
30+
result = contributors_module.get_contributors(
31+
mock_repo, "2022-01-01", "2022-12-31", ""
32+
)
3133

34+
self.assertEqual(len(result), 1)
3235
mock_repo.commits.assert_called_once_with(
3336
since="2022-01-01", until="2022-12-31"
3437
)
@@ -124,9 +127,9 @@ def test_get_all_contributors_with_repository(self, mock_get_contributors):
124127
)
125128

126129
@patch("contributors.contributor_stats.ContributorStats")
127-
def test_get_contributors_skip_users_with_no_commits(self, mock_contributor_stats):
130+
def test_get_contributors_with_single_commit(self, mock_contributor_stats):
128131
"""
129-
Test the get_contributors function skips users with no commits in the date range.
132+
Test get_contributors returns a single contributor for one commit in the date range.
130133
"""
131134
mock_repo = MagicMock()
132135
mock_commit = MagicMock()
@@ -139,8 +142,11 @@ def test_get_contributors_skip_users_with_no_commits(self, mock_contributor_stat
139142
mock_repo.commits.return_value = iter([mock_commit])
140143
ghe = ""
141144

142-
contributors_module.get_contributors(mock_repo, "2022-01-01", "2022-12-31", ghe)
145+
result = contributors_module.get_contributors(
146+
mock_repo, "2022-01-01", "2022-12-31", ghe
147+
)
143148

149+
self.assertEqual(len(result), 1)
144150
mock_repo.commits.assert_called_once_with(
145151
since="2022-01-01", until="2022-12-31"
146152
)
@@ -169,8 +175,11 @@ def test_get_contributors_skip_bot(self, mock_contributor_stats):
169175
mock_repo.commits.return_value = iter([mock_commit])
170176
ghe = ""
171177

172-
contributors_module.get_contributors(mock_repo, "2022-01-01", "2022-12-31", ghe)
178+
result = contributors_module.get_contributors(
179+
mock_repo, "2022-01-01", "2022-12-31", ghe
180+
)
173181

182+
self.assertEqual(result, [])
174183
# Ensure that the bot user is skipped and ContributorStats is never instantiated
175184
mock_contributor_stats.assert_not_called()
176185

0 commit comments

Comments
 (0)