Files
superxas_bec/tests/tests_devices/test_device_scan_info_utils.py
T
wakonig_k 50b8e4d5cd
CI for superxas_bec / test (pull_request) Successful in 1m12s
CI for superxas_bec / test (push) Successful in 1m19s
test: use proper scanstatusmessage instead of simplenamespace
2026-06-05 09:33:10 +02:00

67 lines
2.1 KiB
Python

# pylint: skip-file
import numpy as np
from bec_lib.devicemanager import ScanInfo
from bec_lib.messages import ScanStatusMessage
from superxas_bec.devices.utils.utils import fetch_scan_info
def _build_scan_info(*, info, request_inputs=None, scan_type="fly"):
msg = ScanStatusMessage(
scan_id="scan-id-test",
status="open",
scan_number=1,
session_id="session-id-test",
num_points=2,
num_monitored_readouts=0,
scan_name=info["scan_name"],
scan_type=scan_type,
dataset_number=1,
scan_report_devices=[],
user_metadata={},
readout_priority={},
scan_parameters={},
request_inputs=request_inputs or {"inputs": {}, "kwargs": {}},
info=info,
)
return ScanInfo(msg=msg)
def test_fetch_scan_info_accepts_v4_scan_info_with_positions_list():
scan_info = _build_scan_info(
info={
"scan_name": "xas_simple_scan",
"scan_id": "scan-id-test",
"scan_type": "hardware_triggered",
"positions": [8000.0, 9000.0],
"additional_scan_parameters": {"scan_time": 1.0, "scan_duration": 10.0},
}
)
msg = fetch_scan_info(scan_info)
assert msg.scan_name == "xas_simple_scan"
assert msg.scan_type == "hardware_triggered"
np.testing.assert_array_equal(msg.positions, np.array([8000.0, 9000.0]))
assert msg.additional_scan_parameters["scan_duration"] == 10.0
def test_fetch_scan_info_converts_legacy_fly_scan_type():
scan_info = _build_scan_info(
scan_type="fly",
request_inputs={"inputs": {}, "kwargs": {"scan_time": 1.0, "scan_duration": 10.0}},
info={
"scan_name": "xas_simple_scan",
"scan_id": "scan-id-test",
"scan_type": "fly",
"positions": [8000.0, 9000.0],
"request_inputs": {"inputs": {}, "kwargs": {"scan_time": 1.0, "scan_duration": 10.0}},
},
)
msg = fetch_scan_info(scan_info)
assert msg.scan_type == "hardware_triggered"
assert msg.request_inputs["kwargs"]["scan_time"] == 1.0