Skip to content

Commit

Permalink
Additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed May 29, 2024
1 parent 41a71c6 commit 99d785e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion archon/actor/commands/expose.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ async def abort(
delegate = command.actor.exposure_delegate
expose_data = delegate.expose_data

if delegate is None or delegate.command is None:
if delegate is None or delegate._command is None:
return command.fail(error="Expose command is not running.")

scontr: list[ArchonController]
Expand Down
34 changes: 33 additions & 1 deletion tests/actor/test_command_expose.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ async def fail(command, *args, **kwargs):


async def test_expose_abort(
delegate, actor: ArchonActor, controller: ArchonController, mocker: MockFixture
delegate,
actor: ArchonActor,
controller: ArchonController,
mocker: MockFixture,
):
reset_mock = mocker.patch.object(controller, "reset", return_value=True)

Expand All @@ -163,6 +166,35 @@ async def test_expose_abort(
reset_mock.assert_called_with(reset_timing=True)


async def test_expose_abort_reset_fails(
delegate,
actor: ArchonActor,
controller: ArchonController,
mocker: MockFixture,
):
mocker.patch.object(controller, "reset", side_effect=ArchonError)

await actor.invoke_mock_command("expose --no-readout 1")
await asyncio.sleep(0.5)

abort = await actor.invoke_mock_command("abort --reset")
await abort

assert abort.status.did_fail


async def test_expose_abort_no_command(delegate, actor: ArchonActor):
delegate._command = None

abort = await actor.invoke_mock_command("abort --reset")
await abort

assert abort.status.did_fail

error = abort.replies[-1].message
assert error["error"] == "Expose command is not running."


async def test_expose_abort_no_expose_data(delegate, actor: ArchonActor):
await actor.invoke_mock_command("expose --no-readout 1")
await asyncio.sleep(0.05)
Expand Down

0 comments on commit 99d785e

Please sign in to comment.