test: use proper scanstatusmessage instead of simplenamespace #27

Merged
wakonig_k merged 1 commits from fix/scan_info_test into main 2026-06-05 09:34:58 +02:00
@@ -1,25 +1,42 @@
# pylint: skip-file
from types import SimpleNamespace
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 = SimpleNamespace(
msg=SimpleNamespace(
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,
},
}
)
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)
@@ -31,23 +48,19 @@ def test_fetch_scan_info_accepts_v4_scan_info_with_positions_list():
def test_fetch_scan_info_converts_legacy_fly_scan_type():
scan_info = SimpleNamespace(
msg=SimpleNamespace(
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},
},
}
)
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