Skip to content

Commit

Permalink
Attempt to fix CI build error with new_contributors test
Browse files Browse the repository at this point in the history
  • Loading branch information
tomice committed Sep 28, 2024
1 parent 9a5126a commit e4e6645
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions git_py_stats/tests/test_list_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,54 @@ def test_new_contributors(self, mock_print, mock_run_git_command) -> None:
"""
Test case for new_contributors function.
"""
mock_run_git_command.return_value = "[email protected]|1577836800\n"
list_cmds.new_contributors(self.mock_config, "2020-01-01")

mock_print.assert_called()
mock_run_git_command.assert_called_once()
mock_run_git_command.side_effect = [
"[email protected]|1577854800\n", # First call output
"Author One", # Second call output
]

list_cmds.new_contributors(self.mock_config, "2020-01-01")
for call in mock_print.call_args_list:
print(call)

mock_print.assert_any_call("New contributors since 2020-01-01:\n")
mock_print.assert_any_call("Author One <[email protected]>")

self.assertEqual(mock_run_git_command.call_count, 2)

# Verify the actual calls made to run_git_command.
first_call = call(
[
"git",
"-c",
"log.showSignature=false",
"log",
"--use-mailmap",
"--no-merges",
"--since=2020-01-01",
"--until=2024-12-31",
"--format=%aE|%at",
"--",
]
)
second_call = call(
[
"git",
"-c",
"log.showSignature=false",
"log",
"[email protected]",
"--reverse",
"--use-mailmap",
"--since=2020-01-01",
"--until=2024-12-31",
"--format=%aN",
"--",
"-n",
"1",
]
)
mock_run_git_command.assert_has_calls([first_call, second_call])

@patch("git_py_stats.list_cmds.run_git_command")
@patch("git_py_stats.list_cmds.print")
Expand Down

0 comments on commit e4e6645

Please sign in to comment.