Files
AareDAQ/tests/unit/common/test_aerotech_models.py
appleb_m 6f44da0078
Build and Publish / test (push) Failing after 1m4s
Build and Publish / build (push) Has been skipped
Build and Publish / Build and Deploy Docs (push) Has been skipped
tests: added tests for aerotech, models, autofocus, automation, beamline, diffraction_geometry, enum_pv, face_detection_find_xtal, jfjoch_client, mlbox, my_motor, spreadsheet_updater and worfkflows
2026-04-28 14:35:54 +02:00

75 lines
2.0 KiB
Python

import pytest
from aare.common.aerotech_models import (
TaskEnum, AxisEnum, AerotechRunEnum, VariableTypeEnum,
AerotechAxisStatus, AerotechStatus, AerotechTarget, AerotechRotationScanRequest
)
def test_enums():
assert TaskEnum.TASK_0.value == 0
assert AxisEnum.X.value == "x"
assert AerotechRunEnum.START.value == 1
assert VariableTypeEnum.REAL.value == 1
def test_aerotech_axis_status():
status = AerotechAxisStatus(
enabled=True,
fault=0,
homed=True,
is_fault=False,
moving=False,
position=10.0,
status=1,
velocity=0.0
)
assert status.position == 10.0
assert status.enabled is True
def test_aerotech_status_strings():
axis_status = AerotechAxisStatus(
enabled=True,
fault=0,
homed=True,
is_fault=False,
moving=False,
position=1.234567,
status=1,
velocity=0.1
)
status = AerotechStatus(state="READY", x=axis_status)
pretty = status.to_pretty_string()
assert "STATE: READY" in pretty
assert " X | pos= 1.234567" in pretty
assert "Y: unavailable" in pretty
compact = status.to_compact_string()
assert "state=READY" in compact
assert "x=1.2346 (H, -)" in compact
colored = status.to_colored_string()
assert "STATE:" in colored
assert "READY" in colored
assert "pos=" in colored
assert str(status) == pretty
def test_aerotech_target():
target = AerotechTarget(x=10.0, y=20.0)
payload = target.to_payload()
assert payload == {"x": 10.0, "y": 20.0}
assert "z" not in payload
def test_aerotech_rotation_scan_request():
request = AerotechRotationScanRequest(
rotation_deg=360.0,
time_sec=10.0,
start_pos_deg=0.0,
async_move=True,
exp_time_s=0.1,
incr_omega_deg=1.0,
steps=360
)
payload = request.to_payload()
assert payload["rotation_deg"] == 360.0
assert payload["async"] is True