test(lamni): update x-ray eye align tests to post-EPICS interface
CI for csaxs_bec / test (push) Failing after 1m26s
CI for csaxs_bec / test (pull_request) Failing after 1m24s

Drop test_save_frame (method no longer exists). Rewrite test_update_frame
against dev.fsh/dev.cam_xeye instead of the removed LamNI.alignment module.
Patch the module-level umv in test_tomo_rotate rather than builtins.
This commit is contained in:
x01dc
2026-07-12 18:33:13 +02:00
parent 6d29e05087
commit 69b89fcd85
@@ -13,6 +13,8 @@ from csaxs_bec.bec_ipython_client.plugins.LamNI.x_ray_eye_align import XrayEyeAl
# pylint: disable=redefined-outer-name
# pylint: disable=protected-access
XRAY_EYE_ALIGN = "csaxs_bec.bec_ipython_client.plugins.LamNI.x_ray_eye_align"
class RTControllerMock:
def feedback_disable(self):
@@ -27,59 +29,58 @@ class RTMock(DeviceBase):
enabled = True
def test_save_frame(bec_client_mock):
# TODO - This test can be remove!
client = bec_client_mock
def _make_align(client):
client.device_manager.devices.xeye = DeviceBase(
name="xeye",
config={"enabled": True, "deviceClass": "test_class", "readoutPriority": "baseline"},
)
lamni = LamNI(client)
align = XrayEyeAlign(client, lamni)
with mock.patch(
"csaxs_bec.bec_ipython_client.plugins.LamNI.alignment.epics_put"
) as epics_put_mock:
align.save_frame()
epics_put_mock.assert_called_once_with("XOMNYI-XEYE-SAVFRAME:0", 1)
return XrayEyeAlign(client, lamni)
def test_update_frame(bec_client_mock):
# TODO - This test needs to be revisited, does no longer use the EPICS epics_put/get but device manager methods.
epics_put = "csaxs_bec.bec_ipython_client.plugins.LamNI.alignment.epics_put"
epics_get = "csaxs_bec.bec_ipython_client.plugins.LamNI.alignment.epics_get"
fshopen = "csaxs_bec.bec_ipython_client.plugins.LamNI.alignment.fshopen"
client = bec_client_mock
client.device_manager.devices.xeye = DeviceBase(
name="xeye",
config={"enabled": True, "deviceClass": "test_class", "readoutPriority": "baseline"},
)
lamni = LamNI(client)
align = XrayEyeAlign(client, lamni)
with mock.patch(epics_put) as epics_put_mock:
with mock.patch(epics_get) as epics_get_mock:
with mock.patch(fshopen) as fshopen_mock:
align.update_frame()
epics_put_mock.assert_has_calls(
[
mock.call("XOMNYI-XEYE-ACQDONE:0", 0),
mock.call("XOMNYI-XEYE-ACQ:0", 1),
mock.call("XOMNYI-XEYE-ACQDONE:0", 0),
mock.call("XOMNYI-XEYE-ACQ:0", 0),
]
)
fshopen_mock.assert_called_once()
epics_get_mock.assert_called_with("XOMNYI-XEYE-ACQDONE:0")
align = _make_align(client)
align.gui = mock.MagicMock()
align.alignment_images = []
dev_mock = mock.MagicMock()
dev_mock.cam_xeye.live_mode_enabled.get.return_value = False
with mock.patch(f"{XRAY_EYE_ALIGN}.dev", dev_mock):
with mock.patch(f"{XRAY_EYE_ALIGN}.time.sleep"):
align.update_frame()
dev_mock.cam_xeye.live_mode_enabled.put.assert_called_once_with(True)
dev_mock.fsh.fshopen.assert_called_once()
dev_mock.fsh.fshclose.assert_called_once()
dev_mock.cam_xeye.get_last_image.assert_called_once()
assert len(align.alignment_images) == 1
align.gui.on_live_view_enabled.assert_has_calls([mock.call(True), mock.call(False)])
def test_update_frame_keeps_shutter_open(bec_client_mock):
client = bec_client_mock
align = _make_align(client)
align.gui = mock.MagicMock()
align.alignment_images = []
dev_mock = mock.MagicMock()
dev_mock.cam_xeye.live_mode_enabled.get.return_value = True
with mock.patch(f"{XRAY_EYE_ALIGN}.dev", dev_mock):
with mock.patch(f"{XRAY_EYE_ALIGN}.time.sleep"):
align.update_frame(keep_shutter_open=True)
dev_mock.cam_xeye.live_mode_enabled.put.assert_not_called()
dev_mock.fsh.fshopen.assert_called_once()
dev_mock.fsh.fshclose.assert_not_called()
align.gui.on_live_view_enabled.assert_called_once_with(True)
def test_disable_rt_feedback(bec_client_mock):
# TODO - This test makes sense, check if it works correctly
client = bec_client_mock
client.device_manager.devices.xeye = DeviceBase(
name="xeye",
config={"enabled": True, "deviceClass": "test_class", "readoutPriority": "baseline"},
)
lamni = LamNI(client)
align = XrayEyeAlign(client, lamni)
align = _make_align(client)
client.device_manager.devices.rtx = RTMock(
name="rtx",
config={"enabled": True, "deviceClass": "test_class", "readoutPriority": "baseline"},
@@ -92,14 +93,8 @@ def test_disable_rt_feedback(bec_client_mock):
def test_enable_rt_feedback(bec_client_mock):
# TODO - This test makes sense, check if it works correctly
client = bec_client_mock
client.device_manager.devices.xeye = DeviceBase(
name="xeye",
config={"enabled": True, "deviceClass": "test_class", "readoutPriority": "baseline"},
)
lamni = LamNI(client)
align = XrayEyeAlign(client, lamni)
align = _make_align(client)
client.device_manager.devices.rtx = RTMock(
name="rtx",
config={"enabled": True, "deviceClass": "test_class", "readoutPriority": "baseline"},
@@ -112,24 +107,12 @@ def test_enable_rt_feedback(bec_client_mock):
def test_tomo_rotate(bec_client_mock):
# TODO - This test makes sense, check if it works correctly
import builtins
client = bec_client_mock
client._ip = mock.MagicMock()
client._update_namespace_callback = mock.MagicMock()
client.callbacks = mock.MagicMock()
client.load_high_level_interface("bec_hli")
client.device_manager.devices.xeye = DeviceBase(
name="xeye",
config={"enabled": True, "deviceClass": "test_class", "readoutPriority": "baseline"},
)
lamni = LamNI(client)
align = XrayEyeAlign(client, lamni)
align = _make_align(client)
client.device_manager.devices.lsamrot = RTMock(
name="lsamrot",
config={"enabled": True, "deviceClass": "test_class", "readoutPriority": "baseline"},
)
with mock.patch.object(builtins, "umv") as umv:
with mock.patch(f"{XRAY_EYE_ALIGN}.umv") as umv:
align.tomo_rotate(5)
umv.assert_called_once_with(client.device_manager.devices.lsamrot, 5)
umv.assert_called_once_with(client.device_manager.devices.lsamrot, 5)