From 6a1992f605f73ff486ae2bb8f6353899b64c1e9b Mon Sep 17 00:00:00 2001 From: appel_c Date: Thu, 31 Jul 2025 15:55:08 +0200 Subject: [PATCH] fix(test-mo1-bragg): fix test for mo1_bragg mov succeeds. --- tests/tests_devices/test_mo1_bragg.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/tests_devices/test_mo1_bragg.py b/tests/tests_devices/test_mo1_bragg.py index 0c66506..ac7066b 100644 --- a/tests/tests_devices/test_mo1_bragg.py +++ b/tests/tests_devices/test_mo1_bragg.py @@ -74,15 +74,16 @@ def test_egu(mock_bragg): def test_move_succeeds(mock_bragg): dev = mock_bragg dev.move_abs._read_pv.mock_data = 0 - # Move succeeds - with mock.patch.object(dev.motor_is_moving._read_pv, "mock_data", side_effect=[0, 1]): - status = dev.move(0.5) - # Sleep needed to allow thread to resolive in _move_and_finish, i.e. and the 0.25s sleep inside the function - time.sleep(1) - assert status.done is True - assert status.success is True - assert dev.setpoint.get() == 0.5 - assert dev.move_abs.get() == 1 + dev.motor_is_moving._read_pv.mock_data = 0 + + status = dev.move(0.5) + assert status.done is False + dev.motor_is_moving._read_pv.mock_data = 1 + status.wait(timeout=3) # Callback should within that time + assert status.done is True + assert status.success is True + assert dev.setpoint.get() == 0.5 + assert dev.move_abs.get() == 1 def test_stop_move(mock_bragg):