Files
superxas_bec/tests/tests_devices/test_device_scan_info_utils.py
T

54 lines
1.6 KiB
Python

# pylint: skip-file
from types import SimpleNamespace
import numpy as np
from superxas_bec.devices.utils.utils import fetch_scan_info
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,
},
}
)
)
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 = 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},
},
}
)
)
msg = fetch_scan_info(scan_info)
assert msg.scan_type == "hardware_triggered"
assert msg.request_inputs["kwargs"]["scan_time"] == 1.0