@@ -246,6 +246,12 @@ async def run(coroutine):
246
246
247
247
@pytest .mark .asyncio
248
248
async 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
+
249
255
temp_dir = os .path .join (context .config ["work_dir" ], "timeout" )
250
256
task = {"foo" : "bar" , "credentials" : {"a" : "b" }, "task" : {"task_defn" : True }}
251
257
context .config ["task_script" ] = (sys .executable , TIMEOUT_SCRIPT , temp_dir )
@@ -259,6 +265,7 @@ async def claim_work(*args, **kwargs):
259
265
mocker .patch .object (worker , "reclaim_task" , new = noop_async )
260
266
mocker .patch .object (worker , "generate_cot" , new = noop_sync )
261
267
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" ]))
262
269
mocker .patch .object (worker , "upload_artifacts" , new = noop_async )
263
270
mocker .patch .object (worker , "complete_task" , new = noop_async )
264
271
status = await worker .run_tasks (context )
@@ -267,6 +274,12 @@ async def claim_work(*args, **kwargs):
267
274
268
275
@pytest .mark .asyncio
269
276
async 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
+
270
283
temp_dir = os .path .join (context .config ["work_dir" ], "killed" )
271
284
task = {"foo" : "bar" , "credentials" : {"a" : "b" }, "task" : {"task_defn" : True }}
272
285
context .config ["task_script" ] = (sys .executable , KILLED_SCRIPT , temp_dir )
@@ -280,6 +293,7 @@ async def claim_work(*args, **kwargs):
280
293
mocker .patch .object (worker , "reclaim_task" , new = noop_async )
281
294
mocker .patch .object (worker , "generate_cot" , new = noop_sync )
282
295
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" ]))
283
297
mocker .patch .object (worker , "upload_artifacts" , new = noop_async )
284
298
mocker .patch .object (worker , "complete_task" , new = noop_async )
285
299
status = await worker .run_tasks (context )
@@ -418,13 +432,20 @@ async def test_run_tasks_cancel_cot(context, mocker):
418
432
419
433
@pytest .mark .asyncio
420
434
async 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
+
421
441
mocker .patch ("scriptworker.worker.claim_work" , create_async (_MOCK_CLAIM_WORK_RETURN ))
422
442
mocker .patch ("scriptworker.worker.reclaim_task" , noop_async )
423
443
mocker .patch ("scriptworker.worker.run_task" , noop_async )
424
444
mocker .patch ("scriptworker.worker.generate_cot" , noop_sync )
425
445
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" ]))
426
447
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 )
428
449
429
450
mock_prepare_task = mocker .patch ("scriptworker.worker.prepare_to_run_task" )
430
451
mock_complete_task = mocker .patch ("scriptworker.worker.complete_task" )
0 commit comments