Skip to content

Commit

Permalink
Add specific test for when data was not fetched
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Jul 15, 2024
1 parent 5c0b56d commit 9298ad7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
7 changes: 5 additions & 2 deletions archon/actor/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ async def readout(
except Exception as err:
return self.fail(f"Failed reading out: {err}")

if len(c_fdata) == 0:
self.command.error("No data was fetched.")
return False

self.command.debug(f"Readout completed in {time()-t0:.1f} seconds.")

if write is False:
Expand Down Expand Up @@ -391,8 +395,7 @@ async def readout(
for fd in fdata
]

if len(fdata) > 0:
self.last_exposure_no = fdata[0]["exposure_no"]
self.last_exposure_no = fdata[0]["exposure_no"]

# Prepare checksum information.
write_checksum: bool = self.config["checksum.write"]
Expand Down
19 changes: 19 additions & 0 deletions tests/actor/test_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,25 @@ async def test_delegate_shutter_fails(delegate: ExposureDelegate, mocker):
assert result is False


async def test_delegate_readout_no_fetch_data(delegate: ExposureDelegate):
command = Command("", actor=delegate.actor)
result = await delegate.expose(
command,
[delegate.actor.controllers["sp1"]],
flavour="object",
exposure_time=0.01,
readout=False,
)
assert result is True

assert delegate.expose_data
delegate.expose_data.controllers = []

result = await delegate.readout(command)
assert result is False
assert delegate.command.replies[-1].body["error"] == "No data was fetched."


@pytest.mark.parametrize("window_mode", ["test_mode", "default"])
async def test_delegate_expose_window_mode(delegate: ExposureDelegate, window_mode):
command = Command("", actor=delegate.actor)
Expand Down

0 comments on commit 9298ad7

Please sign in to comment.