Skip to content

Commit a89e2c9

Browse files
committed
tests: misc logic updates
1 parent 7dd1894 commit a89e2c9

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

tests/integration/test_rest_routes.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ async def _assert_db_skyscank8sjobs_coll(
374374
}
375375

376376

377-
async def _patch_manifest(
377+
async def _do_patch(
378378
rc: RestClient,
379379
scan_id: str,
380380
progress: StrDict | None = None,
@@ -460,9 +460,9 @@ async def _patch_progress_and_scan_metadata(
460460
)
461461
# update progress (update `scan_metadata` sometimes--not as important)
462462
if i % 2: # odd
463-
manifest = await _patch_manifest(rc, scan_id, progress=progress)
463+
manifest = await _do_patch(rc, scan_id, progress=progress)
464464
else: # even
465-
manifest = await _patch_manifest(
465+
manifest = await _do_patch(
466466
rc,
467467
scan_id,
468468
progress=progress,
@@ -484,7 +484,7 @@ async def _server_reply_with_event_metadata(rc: RestClient, scan_id: str) -> Str
484484
is_real_event=IS_REAL_EVENT,
485485
)
486486

487-
await _patch_manifest(rc, scan_id, event_metadata=event_metadata)
487+
manifest = await _do_patch(rc, scan_id, event_metadata=event_metadata)
488488

489489
# query by run+event id
490490
resp = await rc.request(
@@ -526,7 +526,7 @@ async def _server_reply_with_event_metadata(rc: RestClient, scan_id: str) -> Str
526526
)
527527
assert [m["scan_id"] for m in resp["manifests"]] == [scan_id]
528528

529-
return event_metadata
529+
return manifest
530530

531531

532532
async def _send_result(
@@ -760,6 +760,12 @@ def get_tms_args(
760760
return tms_args
761761

762762

763+
async def _is_scan_complete(rc: RestClient, scan_id: str) -> bool:
764+
resp = await rc.request("GET", f"/scans/{scan_id}/status")
765+
pprint.pprint(resp)
766+
return resp["scan_complete"]
767+
768+
763769
########################################################################################
764770
# TESTS
765771
########################################################################################
@@ -842,7 +848,7 @@ async def _after_scan_start_logic(
842848
#
843849
# INITIAL UPDATES
844850
#
845-
event_metadata = await _server_reply_with_event_metadata(rc, scan_id)
851+
manifest = await _server_reply_with_event_metadata(rc, scan_id)
846852
# follow-up query
847853
assert await rc.request("GET", f"/scan/{scan_id}/result") == {}
848854
resp = await rc.request("GET", f"/scan/{scan_id}")
@@ -867,17 +873,25 @@ async def _after_scan_start_logic(
867873
#
868874
# SEND RESULT(s)
869875
#
870-
assert not manifest["ewms_task"]["complete"] # workforce is not done
876+
assert not await _is_scan_complete(rc, manifest["scan_id"]) # workforce is not done
871877
result = await _send_result(rc, scan_id, manifest, True)
872878
# wait as long as the server, so it'll mark as complete
873879
await asyncio.sleep(test_wait_before_teardown + 1)
874880
manifest = await rc.request("GET", f"/scan/{scan_id}/manifest")
875-
assert manifest["ewms_task"]["complete"] # workforce is done
881+
assert await _is_scan_complete(rc, manifest["scan_id"]) # workforce is done
876882

877883
#
878884
# DELETE SCAN
879885
#
880-
await _delete_scan(rc, event_metadata, scan_id, manifest, result, True, True)
886+
await _delete_scan(
887+
rc,
888+
manifest["event_metadata"],
889+
scan_id,
890+
manifest,
891+
result,
892+
True,
893+
True,
894+
)
881895

882896

883897
POST_SCAN_BODY_FOR_TEST_01 = dict(**POST_SCAN_BODY, cluster={"foobar": 1})
@@ -1112,7 +1126,7 @@ async def test_100__bad_data(
11121126
#
11131127
# INITIAL UPDATES
11141128
#
1115-
event_metadata = await _server_reply_with_event_metadata(rc, scan_id)
1129+
manifest = await _server_reply_with_event_metadata(rc, scan_id)
11161130
# follow-up query
11171131
assert await rc.request("GET", f"/scan/{scan_id}/result") == {}
11181132
resp = await rc.request("GET", f"/scan/{scan_id}")
@@ -1126,7 +1140,7 @@ async def test_100__bad_data(
11261140
f"400 Client Error: Cannot change an existing event_metadata for url: {rc.address}/scan/{scan_id}/manifest"
11271141
),
11281142
) as e:
1129-
await _patch_manifest(
1143+
await _do_patch(
11301144
rc,
11311145
scan_id,
11321146
event_metadata=dict(
@@ -1173,7 +1187,7 @@ async def test_100__bad_data(
11731187
f"400 Client Error: Cannot change an existing scan_metadata for url: {rc.address}/scan/{scan_id}/manifest"
11741188
),
11751189
) as e:
1176-
await _patch_manifest(rc, scan_id, scan_metadata={"boo": "baz", "bot": "fox"})
1190+
await _do_patch(rc, scan_id, scan_metadata={"boo": "baz", "bot": "fox"})
11771191

11781192
#
11791193
# SEND RESULT
@@ -1218,7 +1232,7 @@ async def test_100__bad_data(
12181232
# wait as long as the server, so it'll mark as complete
12191233
await asyncio.sleep(test_wait_before_teardown)
12201234
manifest = await rc.request("GET", f"/scan/{scan_id}/manifest")
1221-
assert manifest["ewms_task"]["complete"] # workforce is done
1235+
assert await _is_scan_complete(rc, manifest["scan_id"]) # workforce is done
12221236

12231237
#
12241238
# DELETE SCAN

0 commit comments

Comments
 (0)