import pytest from aare.devices.workflow_tools import wait_position class MockMotor: def __init__(self, position): self.readback = position self.name = "MockMotor" def __str__(self): return self.name def test_wait_position_float_no_tolerance(): motor = MockMotor(10.0) wait_position(motor, 10.0) def test_wait_position_float_with_tolerance(): motor = MockMotor(10.05) wait_position(motor, 10.0, tolerance=0.1) def test_wait_position_bytes(): motor = MockMotor(b"Open") wait_position(motor, "Open") wait_position(motor, b"open") def test_wait_position_timeout(): motor = MockMotor(10.0) # We want it to fail, so we set a target it will never reach with pytest.raises(RuntimeError, match="Timeout"): wait_position(motor, 20.0, tolerance=0.1, timeout=0.1) def test_wait_position_invalid_type(): motor = MockMotor([1, 2]) with pytest.raises(RuntimeError, match="could not understand arguments"): wait_position(motor, 10.0)