@@ -102,11 +102,54 @@ def test_new_contributors(self, mock_print, mock_run_git_command) -> None:
102102 """
103103 Test case for new_contributors function.
104104 """
105- mock_run_git_command .return_value = "author1@example.com|1577836800\n "
106- list_cmds .new_contributors (self .mock_config , "2020-01-01" )
107105
108- mock_print .assert_called ()
109- mock_run_git_command .assert_called_once ()
106+ mock_run_git_command .side_effect = [
107+ "author1@example.com|1577854800\n " , # First call output
108+ "Author One" , # Second call output
109+ ]
110+
111+ list_cmds .new_contributors (self .mock_config , "2020-01-01" )
112+ for call in mock_print .call_args_list :
113+ print (call )
114+
115+ mock_print .assert_any_call ("New contributors since 2020-01-01:\n " )
116+ mock_print .assert_any_call ("Author One <author1@example.com>" )
117+
118+ self .assertEqual (mock_run_git_command .call_count , 2 )
119+
120+ # Verify the actual calls made to run_git_command.
121+ first_call = call (
122+ [
123+ "git" ,
124+ "-c" ,
125+ "log.showSignature=false" ,
126+ "log" ,
127+ "--use-mailmap" ,
128+ "--no-merges" ,
129+ "--since=2020-01-01" ,
130+ "--until=2024-12-31" ,
131+ "--format=%aE|%at" ,
132+ "--" ,
133+ ]
134+ )
135+ second_call = call (
136+ [
137+ "git" ,
138+ "-c" ,
139+ "log.showSignature=false" ,
140+ "log" ,
141+ "--author=author1@example.com" ,
142+ "--reverse" ,
143+ "--use-mailmap" ,
144+ "--since=2020-01-01" ,
145+ "--until=2024-12-31" ,
146+ "--format=%aN" ,
147+ "--" ,
148+ "-n" ,
149+ "1" ,
150+ ]
151+ )
152+ mock_run_git_command .assert_has_calls ([first_call , second_call ])
110153
111154 @patch ("git_py_stats.list_cmds.run_git_command" )
112155 @patch ("git_py_stats.list_cmds.print" )
0 commit comments