Skip to content

Commit

Permalink
Update RunController and its tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Mar 15, 2024
1 parent f8de8bb commit 01ed603
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions robot-server/robot_server/runs/run_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 28 additions & 2 deletions robot-server/tests/runs/test_run_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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"),
[
Expand Down

0 comments on commit 01ed603

Please sign in to comment.