@@ -17,6 +17,8 @@ async def test_process_pull_request(app: App, mocker: MockerFixture) -> None:
1717 event_path = Path (__file__ ).parent .parent / "events" / "pr-close.json"
1818
1919 mock_subprocess_run = mocker .patch ("subprocess.run" )
20+ mock_sleep = mocker .patch ("asyncio.sleep" )
21+ mock_sleep .return_value = None
2022
2123 mock_issue = mocker .MagicMock ()
2224 mock_issue .state = "open"
@@ -73,6 +75,11 @@ async def test_process_pull_request(app: App, mocker: MockerFixture) -> None:
7375 },
7476 True ,
7577 )
78+ ctx .should_call_api (
79+ "rest.pulls.async_list" ,
80+ {"owner" : "he0119" , "repo" : "action-test" , "state" : "open" },
81+ mock_pulls_resp ,
82+ )
7683 ctx .should_call_api (
7784 "rest.issues.async_list_comments" ,
7885 {"owner" : "he0119" , "repo" : "action-test" , "issue_number" : 80 },
@@ -92,11 +99,6 @@ async def test_process_pull_request(app: App, mocker: MockerFixture) -> None:
9299 },
93100 True ,
94101 )
95- ctx .should_call_api (
96- "rest.pulls.async_list" ,
97- {"owner" : "he0119" , "repo" : "action-test" , "state" : "open" },
98- mock_pulls_resp ,
99- )
100102
101103 ctx .receive_event (bot , event )
102104
@@ -117,6 +119,8 @@ async def test_process_pull_request(app: App, mocker: MockerFixture) -> None:
117119 any_order = True ,
118120 )
119121
122+ mock_sleep .assert_awaited_once_with (120 )
123+
120124
121125async def test_process_pull_request_not_merged (app : App , mocker : MockerFixture ) -> None :
122126 from src .plugins .publish import pr_close_matcher
@@ -199,6 +203,8 @@ async def test_process_pull_request_skip_plugin_test(
199203 event_path = Path (__file__ ).parent .parent / "events" / "pr-close.json"
200204
201205 mock_subprocess_run = mocker .patch ("subprocess.run" )
206+ mock_sleep = mocker .patch ("asyncio.sleep" )
207+ mock_sleep .return_value = None
202208
203209 mock_issue = mocker .MagicMock ()
204210 mock_issue .state = "open"
@@ -257,6 +263,11 @@ async def test_process_pull_request_skip_plugin_test(
257263 },
258264 True ,
259265 )
266+ ctx .should_call_api (
267+ "rest.pulls.async_list" ,
268+ {"owner" : "he0119" , "repo" : "action-test" , "state" : "open" },
269+ mock_pulls_resp ,
270+ )
260271 ctx .should_call_api (
261272 "rest.issues.async_list_comments" ,
262273 {"owner" : "he0119" , "repo" : "action-test" , "issue_number" : 80 },
@@ -277,11 +288,6 @@ async def test_process_pull_request_skip_plugin_test(
277288 },
278289 True ,
279290 )
280- ctx .should_call_api (
281- "rest.pulls.async_list" ,
282- {"owner" : "he0119" , "repo" : "action-test" , "state" : "open" },
283- mock_pulls_resp ,
284- )
285291
286292 ctx .receive_event (bot , event )
287293
@@ -302,6 +308,8 @@ async def test_process_pull_request_skip_plugin_test(
302308 any_order = True ,
303309 )
304310
311+ mock_sleep .assert_awaited_once_with (120 )
312+
305313
306314async def test_not_publish (app : App , mocker : MockerFixture ) -> None :
307315 """测试与发布无关的拉取请求"""
0 commit comments