@@ -246,6 +246,12 @@ async def run(coroutine):
246246
247247@pytest .mark .asyncio
248248async def test_run_tasks_timeout (context , successful_queue , mocker ):
249+ expected_args = [(context , ["one" , "public/two" , "public/logs/live_backing.log" ]), None ]
250+
251+ async def fake_upload (* args , ** kwargs ):
252+ assert args == expected_args .pop (0 )
253+ return 0
254+
249255 temp_dir = os .path .join (context .config ["work_dir" ], "timeout" )
250256 task = {"foo" : "bar" , "credentials" : {"a" : "b" }, "task" : {"task_defn" : True }}
251257 context .config ["task_script" ] = (sys .executable , TIMEOUT_SCRIPT , temp_dir )
@@ -259,6 +265,7 @@ async def claim_work(*args, **kwargs):
259265 mocker .patch .object (worker , "reclaim_task" , new = noop_async )
260266 mocker .patch .object (worker , "generate_cot" , new = noop_sync )
261267 mocker .patch .object (worker , "prepare_to_run_task" , new = noop_sync )
268+ mocker .patch ("scriptworker.worker.filepaths_in_dir" , create_sync (["one" , "public/two" , "public/logs/live_backing.log" ]))
262269 mocker .patch .object (worker , "upload_artifacts" , new = noop_async )
263270 mocker .patch .object (worker , "complete_task" , new = noop_async )
264271 status = await worker .run_tasks (context )
@@ -267,6 +274,12 @@ async def claim_work(*args, **kwargs):
267274
268275@pytest .mark .asyncio
269276async def test_run_tasks_killed (context , successful_queue , mocker ):
277+ expected_args = [(context , ["one" , "public/two" , "public/logs/live_backing.log" ]), None ]
278+
279+ async def fake_upload (* args , ** kwargs ):
280+ assert args == expected_args .pop (0 )
281+ return 0
282+
270283 temp_dir = os .path .join (context .config ["work_dir" ], "killed" )
271284 task = {"foo" : "bar" , "credentials" : {"a" : "b" }, "task" : {"task_defn" : True }}
272285 context .config ["task_script" ] = (sys .executable , KILLED_SCRIPT , temp_dir )
@@ -280,6 +293,7 @@ async def claim_work(*args, **kwargs):
280293 mocker .patch .object (worker , "reclaim_task" , new = noop_async )
281294 mocker .patch .object (worker , "generate_cot" , new = noop_sync )
282295 mocker .patch .object (worker , "prepare_to_run_task" , new = noop_sync )
296+ mocker .patch ("scriptworker.worker.filepaths_in_dir" , create_sync (["one" , "public/two" , "public/logs/live_backing.log" ]))
283297 mocker .patch .object (worker , "upload_artifacts" , new = noop_async )
284298 mocker .patch .object (worker , "complete_task" , new = noop_async )
285299 status = await worker .run_tasks (context )
@@ -418,13 +432,20 @@ async def test_run_tasks_cancel_cot(context, mocker):
418432
419433@pytest .mark .asyncio
420434async def test_run_tasks_cancel_run_tasks (context , mocker ):
435+ expected_args = [(context , ["one" , "public/two" , "public/logs/live_backing.log" ]), None ]
436+
437+ async def fake_upload (* args , ** kwargs ):
438+ assert args == expected_args .pop (0 )
439+ return 0
440+
421441 mocker .patch ("scriptworker.worker.claim_work" , create_async (_MOCK_CLAIM_WORK_RETURN ))
422442 mocker .patch ("scriptworker.worker.reclaim_task" , noop_async )
423443 mocker .patch ("scriptworker.worker.run_task" , noop_async )
424444 mocker .patch ("scriptworker.worker.generate_cot" , noop_sync )
425445 mocker .patch ("scriptworker.worker.cleanup" , noop_sync )
446+ mocker .patch ("scriptworker.worker.filepaths_in_dir" , create_sync (["one" , "public/two" , "public/logs/live_backing.log" ]))
426447 mocker .patch ("os.path.isfile" , create_sync (True ))
427- mocker .patch ("scriptworker.worker.do_upload" , new = create_async ( result = 0 ) )
448+ mocker .patch ("scriptworker.worker.do_upload" , new = fake_upload )
428449
429450 mock_prepare_task = mocker .patch ("scriptworker.worker.prepare_to_run_task" )
430451 mock_complete_task = mocker .patch ("scriptworker.worker.complete_task" )
0 commit comments