test(flomni): added more tests

This commit is contained in:
2024-02-17 16:40:01 +01:00
parent 8d5b32ebd6
commit 7a97e05e04
2 changed files with 36 additions and 4 deletions

View File

@ -298,10 +298,11 @@ class RtFlomniController(RtController):
}
def laser_tracker_galil_enable(self):
self.get_device_manager().devices.ftrackz.obj.controller.socket_put_confirmed("tracken=1")
self.get_device_manager().devices.ftrackz.obj.controller.socket_put_confirmed("trackyct=0")
self.get_device_manager().devices.ftrackz.obj.controller.socket_put_confirmed("trackzct=0")
self.get_device_manager().devices.ftrackz.obj.controller.socket_put_confirmed("XQ#Tracker")
ftrackz_con = self.get_device_manager().devices.ftrackz.obj.controller
ftrackz_con.socket_put_confirmed("tracken=1")
ftrackz_con.socket_put_confirmed("trackyct=0")
ftrackz_con.socket_put_confirmed("trackzct=0")
ftrackz_con.socket_put_confirmed("XQ#Tracker")
def laser_tracker_on_target(self) -> bool:
self.laser_update_tracker_info()

View File

@ -4,6 +4,7 @@ import pytest
from utils import SocketMock
from ophyd_devices.rt_lamni import RtFlomniController, RtFlomniMotor
from ophyd_devices.rt_lamni.rt_ophyd import RtError
@pytest.fixture()
@ -56,3 +57,33 @@ def test_feedback_enable_with_reset(rt_flomni):
rt_flomni.feedback_enable_with_reset()
laser_tracker_on.assert_called_once()
def test_move_samx_to_scan_region(rt_flomni):
device_manager = rt_flomni.get_device_manager()
device_manager.devices.rtx.user_parameter.get.return_value = 1
rt_flomni.move_samx_to_scan_region(20, 2)
assert mock.call(b"v0\n") not in rt_flomni.sock.put.mock_calls
assert mock.call(b"v1\n") in rt_flomni.sock.put.mock_calls
def test_feedback_enable_without_reset(rt_flomni):
with mock.patch.object(rt_flomni, "set_device_enabled") as set_device_enabled:
with mock.patch.object(rt_flomni, "feedback_is_running", return_value=True):
with mock.patch.object(rt_flomni, "laser_tracker_on") as laser_tracker_on:
rt_flomni.feedback_enable_without_reset()
laser_tracker_on.assert_called_once()
assert mock.call(b"l3\n") in rt_flomni.sock.put.mock_calls
assert mock.call("fsamx", False) in set_device_enabled.mock_calls
assert mock.call("fsamy", False) in set_device_enabled.mock_calls
assert mock.call("foptx", False) in set_device_enabled.mock_calls
assert mock.call("fopty", False) in set_device_enabled.mock_calls
def test_feedback_enable_without_reset_raises(rt_flomni):
with mock.patch.object(rt_flomni, "feedback_is_running", return_value=False):
with mock.patch.object(rt_flomni, "laser_tracker_on") as laser_tracker_on:
with pytest.raises(RtError):
rt_flomni.feedback_enable_without_reset()
laser_tracker_on.assert_called_once()
assert mock.call(b"l3\n") in rt_flomni.sock.put.mock_calls