@@ -255,97 +255,6 @@ def test_filter_multiple_labels(
255255 ["custom_tag" , "another_tag" , "and_another" ],
256256 )
257257
258- @mock .patch ("sync2jira.intermediary.PR.from_github" )
259- def test_handle_github_message_filtering (self , mock_pr_from_github ):
260- """
261- Test 'handle_github_message' filtering for labels, milestone, and other fields.
262- Tests all three filtering conditions in one test case.
263- """
264- # Test 1: Bad label - PR should be filtered out
265- self .mock_github_message_body ["pull_request" ]["labels" ] = [
266- {"name" : "bad_label" }
267- ]
268-
269- response = u .handle_github_message (
270- body = self .mock_github_message_body ,
271- config = self .mock_config ,
272- suffix = "mock_suffix" ,
273- )
274-
275- mock_pr_from_github .assert_not_called ()
276- self .assertEqual (None , response )
277-
278- # Reset for next test
279- mock_pr_from_github .reset_mock ()
280- self .mock_github_message_body ["pull_request" ]["labels" ] = [
281- {"name" : "custom_tag" }
282- ]
283-
284- # Test 2: Bad milestone - PR should be filtered out
285- self .mock_config ["sync2jira" ]["filters" ]["github" ]["org/repo" ][
286- "milestone"
287- ] = 123
288- self .mock_github_message_body ["pull_request" ]["milestone" ] = {"number" : 456 }
289-
290- response = u .handle_github_message (
291- body = self .mock_github_message_body ,
292- config = self .mock_config ,
293- suffix = "mock_suffix" ,
294- )
295-
296- mock_pr_from_github .assert_not_called ()
297- self .assertEqual (None , response )
298-
299- # Reset for next test
300- mock_pr_from_github .reset_mock ()
301- del self .mock_config ["sync2jira" ]["filters" ]["github" ]["org/repo" ]["milestone" ]
302- self .mock_github_message_body ["pull_request" ]["milestone" ] = {
303- "title" : "mock_milestone"
304- }
305-
306- # Test 3: Bad other field (filter1) - PR should be filtered out
307- self .mock_github_message_body ["pull_request" ]["filter1" ] = "filter2"
308-
309- response = u .handle_github_message (
310- body = self .mock_github_message_body ,
311- config = self .mock_config ,
312- suffix = "mock_suffix" ,
313- )
314-
315- mock_pr_from_github .assert_not_called ()
316- self .assertEqual (None , response )
317-
318- @mock .patch (PATH + "Github" )
319- @mock .patch ("sync2jira.intermediary.PR.from_github" )
320- def test_handle_github_message_filtering_passes (
321- self , mock_pr_from_github , mock_github
322- ):
323- """
324- Test 'handle_github_message' when all filters pass (labels, milestone, other fields).
325- """
326- # Set up filters with all three types
327- self .mock_config ["sync2jira" ]["filters" ]["github" ]["org/repo" ]["milestone" ] = 1
328- self .mock_github_message_body ["pull_request" ]["milestone" ] = {
329- "number" : 1 ,
330- "title" : "mock_milestone" ,
331- }
332-
333- # Set up return values
334- mock_pr_from_github .return_value = "Successful Call!"
335- mock_github .return_value = self .mock_github_client
336-
337- # Call function
338- response = u .handle_github_message (
339- body = self .mock_github_message_body ,
340- config = self .mock_config ,
341- suffix = "mock_suffix" ,
342- )
343-
344- # Assert that PR was processed (all filters passed)
345- mock_pr_from_github .assert_called_once ()
346- mock_github .assert_called_with ("mock_token" )
347- self .assertEqual ("Successful Call!" , response )
348-
349258 @mock .patch ("sync2jira.upstream_pr.u_issue.passes_github_filters" )
350259 @mock .patch ("sync2jira.intermediary.PR.from_github" )
351260 def test_handle_github_message_filter_returns_false (
0 commit comments