Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify ad standard det tests #592

Merged
merged 7 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ophyd_async/epics/adsimdetector/_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ def __init__(
lambda: self.name,
adcore.ADBaseDatasetDescriber(self.drv),
),
config_sigs=config_sigs,
config_sigs=(self.drv.acquire_period, self.drv.acquire_time, *config_sigs),
name=name,
)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def create_static_dir_provider_given_fp(fp: FilenameProvider):

@pytest.fixture
def static_path_provider(
static_path_provider_factory: callable,
static_path_provider_factory: Callable,
static_filename_provider: FilenameProvider,
):
return static_path_provider_factory(static_filename_provider)
Expand Down
10 changes: 1 addition & 9 deletions tests/epics/adaravis/test_aravis.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ async def test_can_read(test_adaravis: adaravis.AravisDetector):
async def test_decribe_describes_writer_dataset(
test_adaravis: adaravis.AravisDetector, one_shot_trigger_info: TriggerInfo
):
set_mock_value(test_adaravis._writer.hdf.file_path_exists, True)
set_mock_value(test_adaravis._writer.hdf.capture, True)

assert await test_adaravis.describe() == {}
await test_adaravis.stage()
await test_adaravis.prepare(one_shot_trigger_info)
Expand All @@ -106,10 +103,7 @@ async def test_can_collect(
one_shot_trigger_info: TriggerInfo,
):
path_info = static_path_provider()
full_file_name = path_info.directory_path / "foo.h5"
set_mock_value(test_adaravis.hdf.full_file_name, str(full_file_name))
set_mock_value(test_adaravis._writer.hdf.file_path_exists, True)
set_mock_value(test_adaravis._writer.hdf.capture, True)
full_file_name = path_info.directory_path / f"{path_info.filename}.h5"
await test_adaravis.stage()
await test_adaravis.prepare(one_shot_trigger_info)
docs = [(name, doc) async for name, doc in test_adaravis.collect_asset_docs(1)]
Expand All @@ -135,8 +129,6 @@ async def test_can_collect(
async def test_can_decribe_collect(
test_adaravis: adaravis.AravisDetector, one_shot_trigger_info: TriggerInfo
):
set_mock_value(test_adaravis._writer.hdf.file_path_exists, True)
set_mock_value(test_adaravis._writer.hdf.capture, True)
assert (await test_adaravis.describe_collect()) == {}
await test_adaravis.stage()
await test_adaravis.prepare(one_shot_trigger_info)
Expand Down
13 changes: 3 additions & 10 deletions tests/epics/adkinetix/test_kinetix.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def setup_trigger_mode(trig_mode: DetectorTrigger):


async def test_hints_from_hdf_writer(test_adkinetix: adkinetix.KinetixDetector):
assert test_adkinetix.hints == {"fields": ["test_adkinetix1"]}
assert test_adkinetix.hints == {"fields": [test_adkinetix.name]}


async def test_can_read(test_adkinetix: adkinetix.KinetixDetector):
Expand All @@ -62,9 +62,6 @@ async def test_can_read(test_adkinetix: adkinetix.KinetixDetector):
async def test_decribe_describes_writer_dataset(
test_adkinetix: adkinetix.KinetixDetector, one_shot_trigger_info: TriggerInfo
):
set_mock_value(test_adkinetix._writer.hdf.file_path_exists, True)
set_mock_value(test_adkinetix._writer.hdf.capture, True)

assert await test_adkinetix.describe() == {}
await test_adkinetix.stage()
await test_adkinetix.prepare(one_shot_trigger_info)
Expand All @@ -85,10 +82,8 @@ async def test_can_collect(
one_shot_trigger_info: TriggerInfo,
):
path_info = static_path_provider()
full_file_name = path_info.directory_path / "foo.h5"
set_mock_value(test_adkinetix.hdf.full_file_name, str(full_file_name))
set_mock_value(test_adkinetix._writer.hdf.file_path_exists, True)
set_mock_value(test_adkinetix._writer.hdf.capture, True)
full_file_name = path_info.directory_path / f"{path_info.filename}.h5"

await test_adkinetix.stage()
await test_adkinetix.prepare(one_shot_trigger_info)
docs = [(name, doc) async for name, doc in test_adkinetix.collect_asset_docs(1)]
Expand All @@ -114,8 +109,6 @@ async def test_can_collect(
async def test_can_decribe_collect(
test_adkinetix: adkinetix.KinetixDetector, one_shot_trigger_info: TriggerInfo
):
set_mock_value(test_adkinetix._writer.hdf.file_path_exists, True)
set_mock_value(test_adkinetix._writer.hdf.capture, True)
assert (await test_adkinetix.describe_collect()) == {}
await test_adkinetix.stage()
await test_adkinetix.prepare(one_shot_trigger_info)
Expand Down
54 changes: 31 additions & 23 deletions tests/epics/adpilatus/test_pilatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,24 @@
from unittest.mock import patch

import pytest
from bluesky.run_engine import RunEngine

from ophyd_async.core import (
DetectorTrigger,
DeviceCollector,
PathProvider,
TriggerInfo,
set_mock_value,
)
from ophyd_async.epics import adpilatus
from ophyd_async.epics import adcore, adpilatus


@pytest.fixture
async def test_adpilatus(
RE: RunEngine,
static_path_provider: PathProvider,
) -> adpilatus.PilatusDetector:
async with DeviceCollector(mock=True):
test_adpilatus = adpilatus.PilatusDetector("PILATUS:", static_path_provider)

return test_adpilatus


async def test_deadtime_overridable(static_path_provider: PathProvider):
async with DeviceCollector(mock=True):
test_adpilatus = adpilatus.PilatusDetector(
"PILATUS:",
static_path_provider,
readout_time=adpilatus.PilatusReadoutTime.pilatus2,
)
pilatus_controller = test_adpilatus.controller
def test_adpilatus(ad_standard_det_factory) -> adpilatus.PilatusDetector:
return ad_standard_det_factory(adpilatus.PilatusDetector)


async def test_deadtime_overridable(test_adpilatus: adpilatus.PilatusDetector):
pilatus_controller = test_adpilatus._controller
pilatus_controller._readout_time = adpilatus.PilatusReadoutTime.pilatus2

# deadtime invariant with exposure time
assert pilatus_controller.get_deadtime(0) == 2.28e-3

Expand Down Expand Up @@ -110,7 +97,7 @@ async def _trigger(


async def test_hints_from_hdf_writer(test_adpilatus: adpilatus.PilatusDetector):
assert test_adpilatus.hints == {"fields": ["test_adpilatus"]}
assert test_adpilatus.hints == {"fields": [test_adpilatus.name]}


async def test_unsupported_trigger_excepts(test_adpilatus: adpilatus.PilatusDetector):
Expand Down Expand Up @@ -144,3 +131,24 @@ async def dummy_open(multiplier: int = 0):
)
assert (await test_adpilatus.drv.acquire_time.get_value()) == 1.0
assert (await test_adpilatus.drv.acquire_period.get_value()) == 1.0 + 950e-6


async def test_pilatus_controller(test_adpilatus: adpilatus.PilatusDetector):
pilatus = test_adpilatus._controller
pilatus_driver = pilatus._drv
set_mock_value(pilatus_driver.armed, True)
await pilatus.prepare(TriggerInfo(number=1, trigger=DetectorTrigger.constant_gate))
await pilatus.arm()
await pilatus.wait_for_idle()

assert await pilatus_driver.num_images.get_value() == 1
assert await pilatus_driver.image_mode.get_value() == adcore.ImageMode.multiple
assert (
await pilatus_driver.trigger_mode.get_value()
== adpilatus.PilatusTriggerMode.ext_enable
)
assert await pilatus_driver.acquire.get_value() is True

await pilatus.disarm()

assert await pilatus_driver.acquire.get_value() is False
46 changes: 0 additions & 46 deletions tests/epics/adpilatus/test_pilatus_controller.py

This file was deleted.

32 changes: 0 additions & 32 deletions tests/epics/adsimdetector/test_adsim_controller.py

This file was deleted.

Loading