@@ -34,6 +34,7 @@ def test_measure_time_to_first_response(self):
3434 # Set up the mock GitHub issues
3535 mock_issue1 = MagicMock ()
3636 mock_issue1 .comments = 2
37+ mock_issue1 .issue .user .login = "issue_owner"
3738 mock_issue1 .created_at = "2023-01-01T00:00:00Z"
3839
3940 # Set up the mock GitHub issue comments
@@ -55,6 +56,7 @@ def test_measure_time_to_first_response_no_comments(self):
5556 # Set up mock issues with no comments
5657 mock_issue1 = MagicMock ()
5758 mock_issue1 .comments = 0
59+ mock_issue1 .issue .user .login = "issue_owner"
5860 mock_issue1 .created_at = "2023-01-01T00:00:00Z"
5961
6062 # Call the function
@@ -70,6 +72,7 @@ def test_measure_time_to_first_response_with_pull_request_comments(self):
7072 # Set up the mock GitHub issues
7173 mock_issue1 = MagicMock ()
7274 mock_issue1 .comments = 2
75+ mock_issue1 .issue .user .login = "issue_owner"
7376 mock_issue1 .created_at = "2023-01-01T00:00:00Z"
7477 mock_issue1 .pull_request_urls = {"url" : "https://api.github.com/repos/owner/repo/pulls/1" }
7578
@@ -93,6 +96,7 @@ def test_measure_time_to_first_response_issue_comment_faster(self):
9396 # Set up the mock GitHub issues
9497 mock_issue1 = MagicMock ()
9598 mock_issue1 .comments = 2
99+ mock_issue1 .issue .user .login = "issue_owner"
96100 mock_issue1 .created_at = "2023-01-01T00:00:00Z"
97101 mock_issue1 .pull_request_urls = {"url" : "https://api.github.com/repos/owner/repo/pulls/1" }
98102
@@ -119,6 +123,7 @@ def test_measure_time_to_first_response_pull_request_comment_faster(self):
119123 # Set up the mock GitHub issues
120124 mock_issue1 = MagicMock ()
121125 mock_issue1 .comments = 2
126+ mock_issue1 .issue .user .login = "issue_owner"
122127 mock_issue1 .created_at = "2023-01-01T00:00:00Z"
123128 mock_issue1 .pull_request_urls = {"url" : "https://api.github.com/repos/owner/repo/pulls/1" }
124129
@@ -144,6 +149,7 @@ def test_measure_time_to_first_response_ignore_users(self):
144149 # Set up the mock GitHub issues
145150 mock_issue1 = MagicMock ()
146151 mock_issue1 .comments = 4
152+ mock_issue1 .issue .user .login = "issue_owner"
147153 mock_issue1 .created_at = "2023-01-01T00:00:00Z"
148154
149155 # Set up the mock GitHub issue comments (one ignored, one not ignored)
@@ -176,6 +182,7 @@ def test_measure_time_to_first_response_only_ignored_users(self):
176182 # Set up the mock GitHub issues
177183 mock_issue1 = MagicMock ()
178184 mock_issue1 .comments = 4
185+ mock_issue1 .issue .user .login = "issue_owner"
179186 mock_issue1 .created_at = "2023-01-01T00:00:00Z"
180187 mock_issue1 .pull_request_urls = {"url" : "https://api.github.com/repos/owner/repo/pulls/1" }
181188
@@ -206,6 +213,40 @@ def test_measure_time_to_first_response_only_ignored_users(self):
206213 # Check the results
207214 self .assertEqual (result , expected_result )
208215
216+ def test_measure_time_to_first_response_ignore_issue_owners_comment (self ):
217+ """Test that measure_time_to_first_response ignore issue owner's comment."""
218+ # Set up the mock GitHub issues
219+ mock_issue1 = MagicMock ()
220+ mock_issue1 .comments = 4
221+ mock_issue1 .issue .user .login = "issue_owner"
222+ mock_issue1 .created_at = "2023-01-01T00:00:00Z"
223+ mock_issue1 .pull_request_urls = {"url" : "https://api.github.com/repos/owner/repo/pulls/1" }
224+
225+ # Set up the mock GitHub issue comments
226+ mock_comment1 = MagicMock ()
227+ mock_comment1 .user .login = "issue_owner"
228+ mock_comment1 .created_at = datetime .fromisoformat ("2023-01-02T00:00:00Z" )
229+ mock_comment2 = MagicMock ()
230+ mock_comment2 .user .login = "other_user"
231+ mock_comment2 .created_at = datetime .fromisoformat ("2023-01-05T00:00:00Z" )
232+ mock_issue1 .issue .comments .return_value = [mock_comment1 , mock_comment2 ]
233+
234+ # Set up the mock GitHub pull request comments
235+ mock_pr_comment1 = MagicMock ()
236+ mock_pr_comment1 .user .login = "issue_owner"
237+ mock_pr_comment1 .submitted_at = datetime .fromisoformat ("2023-01-03T00:00:00Z" )
238+ mock_pr_comment2 = MagicMock ()
239+ mock_pr_comment2 .user .login = "other_user"
240+ mock_pr_comment2 .submitted_at = datetime .fromisoformat ("2023-01-04T00:00:00Z" )
241+ mock_issue1 .issue .pull_request ().reviews .return_value = [mock_pr_comment1 , mock_pr_comment2 ]
242+
243+ # Call the function
244+ result = measure_time_to_first_response (mock_issue1 , None )
245+ expected_result = timedelta (days = 3 )
246+
247+ # Check the results
248+ self .assertEqual (result , expected_result )
249+
209250
210251class TestGetAverageTimeToFirstResponse (unittest .TestCase ):
211252 """Test the get_average_time_to_first_response function."""
0 commit comments