38 lines
1.7 KiB
Python
38 lines
1.7 KiB
Python
"""Module to test epics devices."""
|
|
|
|
import pytest
|
|
from ophyd_devices.tests.utils import patched_device
|
|
|
|
from csaxs_bec.devices.epics.fast_shutter import cSAXSFastEpicsShutter
|
|
|
|
|
|
@pytest.fixture
|
|
def fast_shutter_device():
|
|
"""Fixture to create a patched cSAXSFastEpicsShutter device for testing."""
|
|
with patched_device(cSAXSFastEpicsShutter, name="fsh", prefix="X12SA-ES1-TTL:") as device:
|
|
yield device
|
|
|
|
|
|
def test_fast_shutter_methods(fast_shutter_device):
|
|
"""Test the user-facing methods of the cSAXSFastEpicsShutter device."""
|
|
assert fast_shutter_device.name == "fsh", "Device name should be 'fsh'"
|
|
assert fast_shutter_device.prefix == "X12SA-ES1-TTL:", "Device prefix is 'X12SA-ES1-TTL:'"
|
|
# Test fshopen and fshclose
|
|
fast_shutter_device.fshopen()
|
|
assert fast_shutter_device.shutter.get() == 1, "Shutter should be open (1) after fshopen()"
|
|
assert fast_shutter_device.fshstatus() == 1, "fshstatus should return 1 when shutter is open"
|
|
|
|
fast_shutter_device.fshclose()
|
|
assert fast_shutter_device.shutter.get() == 0, "Shutter should be closed (0) after fshclose()"
|
|
assert fast_shutter_device.fshstatus() == 0, "fshstatus should return 0 when shutter is closed"
|
|
|
|
# shutter_readback is connected to separate PV.
|
|
fast_shutter_device.shutter_readback._read_pv.mock_data = 1 # Simulate readback showing open
|
|
assert (
|
|
fast_shutter_device.fshstatus_readback() == 1
|
|
), "fshstatus_readback should return 1 when shutter readback shows open"
|
|
fast_shutter_device.shutter_readback._read_pv.mock_data = 0 # Simulate readback showing closed
|
|
assert (
|
|
fast_shutter_device.fshstatus_readback() == 0
|
|
), "fshstatus_readback should return 0 when shutter readback shows closed"
|