Skip to content

Commit 287fe89

Browse files
author
Andrei Neagu
committed
added tests for errors
1 parent a78438b commit 287fe89

File tree

1 file changed

+56
-1
lines changed
  • services/dynamic-scheduler/tests/unit/services/generic_scheduler

1 file changed

+56
-1
lines changed

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

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@
3434
restart_revert_operation_step_in_error,
3535
start_operation,
3636
)
37+
from simcore_service_dynamic_scheduler.services.generic_scheduler._core import get_core
3738
from simcore_service_dynamic_scheduler.services.generic_scheduler._errors import (
3839
CannotCancelWhileWaitingForManualInterventionError,
3940
InitialOperationContextKeyNotAllowedError,
4041
OperationContextValueIsNoneError,
4142
ProvidedOperationContextKeysAreMissingError,
43+
StepNameNotInCurrentGroupError,
44+
StepNotInErrorStateError,
45+
StepNotWaitingForManualInterventionError,
4246
)
4347
from simcore_service_dynamic_scheduler.services.generic_scheduler._models import (
4448
OperationContext,
@@ -1231,7 +1235,58 @@ async def test_restart_revert_operation_step_in_error(
12311235
await _ensure_keys_in_store(selected_app, expected_keys=set())
12321236

12331237

1234-
# TODO: add tests for all errors raised by `restart_operation_step_in_error`
1238+
@pytest.mark.parametrize("app_count", [10])
1239+
@pytest.mark.parametrize("in_manual_intervention", [True, False])
1240+
async def test_errors_with_restart_operation_step_in_error(
1241+
preserve_caplog_for_async_logging: None,
1242+
steps_call_order: list[tuple[str, str]],
1243+
selected_app: FastAPI,
1244+
register_operation: Callable[[OperationName, Operation], None],
1245+
operation_name: OperationName,
1246+
in_manual_intervention: bool,
1247+
):
1248+
operation: Operation = [
1249+
SingleStepGroup(_S1),
1250+
ParallelStepGroup(_S2, _S3, _S4),
1251+
ParallelStepGroup(_SF1, _FCR1), # sleeps here forever
1252+
]
1253+
register_operation(operation_name, operation)
1254+
1255+
schedule_id = await start_operation(selected_app, operation_name, {})
1256+
assert isinstance(schedule_id, ScheduleId)
1257+
1258+
await ensure_expected_order(
1259+
steps_call_order,
1260+
[
1261+
CreateSequence(_S1),
1262+
CreateRandom(_S2, _S3, _S4),
1263+
CreateRandom(_SF1, _FCR1),
1264+
],
1265+
)
1266+
1267+
with pytest.raises(StepNameNotInCurrentGroupError):
1268+
await get_core(selected_app).restart_operation_step_in_error(
1269+
schedule_id,
1270+
_S5.get_step_name(),
1271+
in_manual_intervention=in_manual_intervention,
1272+
)
1273+
1274+
with pytest.raises(StepNotInErrorStateError):
1275+
await get_core(selected_app).restart_operation_step_in_error(
1276+
schedule_id,
1277+
_SF1.get_step_name(),
1278+
in_manual_intervention=in_manual_intervention,
1279+
)
1280+
1281+
if not in_manual_intervention:
1282+
# force restart of step as it would be in manual intervention
1283+
# this is not allowed
1284+
with pytest.raises(StepNotWaitingForManualInterventionError):
1285+
await get_core(selected_app).restart_operation_step_in_error(
1286+
schedule_id,
1287+
_FCR1.get_step_name(),
1288+
in_manual_intervention=True,
1289+
)
12351290

12361291

12371292
@pytest.mark.parametrize("app_count", [10])

0 commit comments

Comments
 (0)