| 
34 | 34 |     restart_revert_operation_step_in_error,  | 
35 | 35 |     start_operation,  | 
36 | 36 | )  | 
 | 37 | +from simcore_service_dynamic_scheduler.services.generic_scheduler._core import get_core  | 
37 | 38 | from simcore_service_dynamic_scheduler.services.generic_scheduler._errors import (  | 
38 | 39 |     CannotCancelWhileWaitingForManualInterventionError,  | 
39 | 40 |     InitialOperationContextKeyNotAllowedError,  | 
40 | 41 |     OperationContextValueIsNoneError,  | 
41 | 42 |     ProvidedOperationContextKeysAreMissingError,  | 
 | 43 | +    StepNameNotInCurrentGroupError,  | 
 | 44 | +    StepNotInErrorStateError,  | 
 | 45 | +    StepNotWaitingForManualInterventionError,  | 
42 | 46 | )  | 
43 | 47 | from simcore_service_dynamic_scheduler.services.generic_scheduler._models import (  | 
44 | 48 |     OperationContext,  | 
@@ -1231,7 +1235,58 @@ async def test_restart_revert_operation_step_in_error(  | 
1231 | 1235 |     await _ensure_keys_in_store(selected_app, expected_keys=set())  | 
1232 | 1236 | 
 
  | 
1233 | 1237 | 
 
  | 
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 | +            )  | 
1235 | 1290 | 
 
  | 
1236 | 1291 | 
 
  | 
1237 | 1292 | @pytest.mark.parametrize("app_count", [10])  | 
 | 
0 commit comments