Skip to content

Commit 38f3b88

Browse files
author
Andrei Neagu
committed
fixeed broken tests
1 parent 3f79e14 commit 38f3b88

File tree

1 file changed

+53
-9
lines changed
  • services/dynamic-scheduler/tests/unit/services/generic_scheduler

1 file changed

+53
-9
lines changed

services/dynamic-scheduler/tests/unit/services/generic_scheduler/test__core.py

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,43 @@ async def _esnure_steps_have_status(
399399
raise AssertionError(msg) from None
400400

401401

402+
async def _ensure_one_step_in_manual_intervention(
403+
app: FastAPI,
404+
schedule_id: ScheduleId,
405+
operation_name: OperationName,
406+
*,
407+
step_group_name: StepGroupName,
408+
steps: Iterable[type[BaseStep]],
409+
) -> None:
410+
store_proxies = [
411+
StepStoreProxy(
412+
store=Store.get_from_app_state(app),
413+
schedule_id=schedule_id,
414+
operation_name=operation_name,
415+
step_group_name=step_group_name,
416+
step_name=step.get_step_name(),
417+
is_executing=True,
418+
)
419+
for step in steps
420+
]
421+
422+
async for attempt in AsyncRetrying(**_RETRY_PARAMS):
423+
with attempt: # noqa: SIM117
424+
reuires_intervention = False
425+
for proxy in store_proxies:
426+
try:
427+
requires_manual_intervention = await proxy.read(
428+
"requires_manual_intervention"
429+
)
430+
if requires_manual_intervention:
431+
reuires_intervention = True
432+
break
433+
except NoDataFoundError:
434+
pass
435+
436+
assert reuires_intervention is True
437+
438+
402439
############## TESTS ##############
403440

404441

@@ -853,7 +890,7 @@ async def test_fails_during_revert_is_in_error_state(
853890
RevertRandom(_S2, _S3, _S4),
854891
RevertSequence(_S1),
855892
],
856-
id="s1p3s1(1s)",
893+
id="s1p3s1(1sf)",
857894
),
858895
pytest.param(
859896
Operation(
@@ -870,7 +907,7 @@ async def test_fails_during_revert_is_in_error_state(
870907
RevertRandom(_S2, _S3, _S4, _SF2, _SF1),
871908
RevertSequence(_S1),
872909
],
873-
id="s1p4(1s)",
910+
id="s1p5(2sf)",
874911
),
875912
],
876913
)
@@ -1105,21 +1142,28 @@ async def test_wait_for_manual_intervention(
11051142

11061143
await ensure_keys_in_store(selected_app, expected_keys=formatted_expected_keys)
11071144

1145+
group_index = len(expected_order) - 1
1146+
step_group_name = operation.step_groups[group_index].get_step_group_name(
1147+
index=group_index
1148+
)
11081149
await _esnure_steps_have_status(
11091150
selected_app,
11101151
schedule_id,
11111152
operation_name,
1112-
step_group_name=operation.step_groups[
1113-
len(expected_order) - 1
1114-
].get_step_group_name(index=len(expected_order) - 1),
1153+
step_group_name=step_group_name,
11151154
steps=expected_order[-1].steps,
11161155
)
11171156

11181157
# even if cancelled, state of waiting for manual intervention remains the same
1119-
async for attempt in AsyncRetrying(**_RETRY_PARAMS):
1120-
with attempt: # noqa: SIM117
1121-
with pytest.raises(CannotCancelWhileWaitingForManualInterventionError):
1122-
await cancel_operation(selected_app, schedule_id)
1158+
await _ensure_one_step_in_manual_intervention(
1159+
selected_app,
1160+
schedule_id,
1161+
operation_name,
1162+
step_group_name=step_group_name,
1163+
steps=expected_order[-1].steps,
1164+
)
1165+
with pytest.raises(CannotCancelWhileWaitingForManualInterventionError):
1166+
await cancel_operation(selected_app, schedule_id)
11231167

11241168
await ensure_keys_in_store(selected_app, expected_keys=formatted_expected_keys)
11251169

0 commit comments

Comments
 (0)