Skip to content

Commit

Permalink
Test for describe, collect
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Apr 15, 2024
1 parent d063273 commit 3a9ea0c
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/epics/areadetector/test_aravis.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,75 @@ async def test_hints_from_hdf_writer(adaravis: AravisDetector):
assert adaravis.hints == {"fields": ["adaravis"]}


async def test_can_read(adaravis: AravisDetector):
# Standard detector can be used as Readable
assert (await adaravis.read()) == {}


async def test_decribe_describes_writer_dataset(adaravis: AravisDetector):
set_sim_value(adaravis._writer.hdf.file_path_exists, True)
set_sim_value(adaravis._writer.hdf.capture, True)

assert adaravis.describe() == {}
await adaravis.stage()
assert adaravis.describe() == {
"adaravis": {
"source": "sim://HDF:FullFileName_RBV",
"shape": (0, 0),
"dtype": "array",
"external": "STREAM:",
}
}


async def test_can_collect(
adaravis: AravisDetector, static_directory_provider: DirectoryProvider
):
directory_info = static_directory_provider()
full_file_name = directory_info.root / directory_info.resource_dir / "foo.h5"
set_sim_value(adaravis.hdf.full_file_name, str(full_file_name))
set_sim_value(adaravis._writer.hdf.file_path_exists, True)
set_sim_value(adaravis._writer.hdf.capture, True)
await adaravis.stage()
docs = [(name, doc) async for name, doc in adaravis.collect_asset_docs(1)]
assert len(docs) == 2
assert docs[0][0] == "stream_resource"
stream_resource = docs[0][1]
sr_uid = stream_resource["uid"]
assert stream_resource["data_key"] == "adaravis"
assert stream_resource["spec"] == "AD_HDF5_SWMR_SLICE"
assert stream_resource["root"] == str(directory_info.root)
assert stream_resource["resource_path"] == str(
directory_info.resource_dir / "foo.h5"
)
assert stream_resource["path_semantics"] == "posix"
assert stream_resource["resource_kwargs"] == {
"path": "/entry/data/data",
"multiplier": 1,
"timestamps": "/entry/instrument/NDAttributes/NDArrayTimeStamp",
}
assert docs[1][0] == "stream_datum"
stream_datum = docs[1][1]
assert stream_datum["stream_resource"] == sr_uid
assert stream_datum["seq_nums"] == {"start": 0, "stop": 0}
assert stream_datum["indices"] == {"start": 0, "stop": 1}


async def test_can_decribe_collect(adaravis: AravisDetector):
set_sim_value(adaravis._writer.hdf.file_path_exists, True)
set_sim_value(adaravis._writer.hdf.capture, True)
assert (await adaravis.describe_collect()) == {}
await adaravis.stage()
assert (await adaravis.describe_collect()) == {
"adaravis": {
"source": "sim://HDF:FullFileName_RBV",
"shape": (0, 0),
"dtype": "array",
"external": "STREAM:",
}
}


async def test_unsupported_trigger_excepts(adaravis: AravisDetector):
set_sim_value(adaravis.drv.model, "Manta G-125")
set_sim_value(adaravis.drv.pixel_format, "Mono12Packed")
Expand Down

0 comments on commit 3a9ea0c

Please sign in to comment.