diff --git a/robot-server/robot_server/runs/run_controller.py b/robot-server/robot_server/runs/run_controller.py index 66ff5210081..9b048d252ff 100644 --- a/robot-server/robot_server/runs/run_controller.py +++ b/robot-server/robot_server/runs/run_controller.py @@ -85,6 +85,9 @@ def create_action( log.info(f'Stopping run "{self._run_id}".') self._task_runner.run(self._engine_store.runner.stop) + elif action_type == RunActionType.COMPLETE_RECOVERY: + self._engine_store.runner.complete_recovery() + except ProtocolEngineError as e: raise RunActionNotAllowedError(message=e.message, wrapping=[e]) from e diff --git a/robot-server/tests/runs/test_run_controller.py b/robot-server/tests/runs/test_run_controller.py index da433043650..293380a3c24 100644 --- a/robot-server/tests/runs/test_run_controller.py +++ b/robot-server/tests/runs/test_run_controller.py @@ -168,7 +168,7 @@ async def test_create_play_action_to_start( ) -async def test_create_pause_action( +def test_create_pause_action( decoy: Decoy, mock_engine_store: EngineStore, mock_run_store: RunStore, @@ -193,7 +193,7 @@ async def test_create_pause_action( decoy.verify(mock_engine_store.runner.pause(), times=1) -async def test_create_stop_action( +def test_create_stop_action( decoy: Decoy, mock_engine_store: EngineStore, mock_run_store: RunStore, @@ -219,6 +219,32 @@ async def test_create_stop_action( decoy.verify(mock_task_runner.run(mock_engine_store.runner.stop), times=1) +def test_create_complete_recovery_action( + decoy: Decoy, + mock_engine_store: EngineStore, + mock_run_store: RunStore, + mock_task_runner: TaskRunner, + run_id: str, + subject: RunController, +) -> None: + """It should call `complete_recovery()` on the underlying engine store.""" + result = subject.create_action( + action_id="some-action-id", + action_type=RunActionType.COMPLETE_RECOVERY, + created_at=datetime(year=2021, month=1, day=1), + action_payload=[], + ) + + assert result == RunAction( + id="some-action-id", + actionType=RunActionType.COMPLETE_RECOVERY, + createdAt=datetime(year=2021, month=1, day=1), + ) + + decoy.verify(mock_run_store.insert_action(run_id, result), times=1) + decoy.verify(mock_engine_store.runner.complete_recovery()) + + @pytest.mark.parametrize( ("action_type", "exception"), [