From e9428ca64dece6f9a9c2be6fc5867c635b08449c Mon Sep 17 00:00:00 2001 From: Dawn Date: Mon, 17 Aug 2026 17:00:26 +0200 Subject: [PATCH] test: pin the Sample-alignment motion-watch exception Robot motion switches to the combined view; alignment beginning switches straight back while busy is still set, and staying busy in alignment never re-triggers. Piggybacks on the init test's window - extra MainWindow constructions feed the PySide teardown flake. Co-Authored-By: Claude Fable 5 --- tests/unit/gui/test_main_window.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/unit/gui/test_main_window.py b/tests/unit/gui/test_main_window.py index c1cd7040..45f6c84e 100644 --- a/tests/unit/gui/test_main_window.py +++ b/tests/unit/gui/test_main_window.py @@ -14,7 +14,7 @@ def mock_ui_state(): yield mock -def test_main_window_init(qtbot, mock_ui_state): +def test_main_window_init(qtbot, mock_ui_state, daq_status_factory): with ( patch("requests.get") as mock_get, patch("aare.gui.main_window.DAQWorker"), @@ -71,6 +71,25 @@ def test_main_window_init(qtbot, mock_ui_state): win.data_collection._emit_change_energy() assert sent and abs(sent[0] - 12400.0) < 1e-6 + # Motion watch: robot motion switches to the combined beamline view; + # alignment beginning switches straight back to the sample camera even + # while the busy flag is still set — busy moves during Sample + # alignment ARE the alignment, so it never re-triggers the switch. + win.update_daq_status( + daq_status_factory(state=BeamlineStateEnum.RobotSampleExchange, busy=True) + ) + assert win._watching_motion + assert win.video_tab.currentWidget() is win.beamline_combined_panel + win.update_daq_status( + daq_status_factory(state=BeamlineStateEnum.SampleAlignment, busy=True) + ) + assert not win._watching_motion + assert win.video_tab.currentWidget() is win.sample_camera + win.update_daq_status( + daq_status_factory(state=BeamlineStateEnum.SampleAlignment, busy=True) + ) + assert not win._watching_motion + def test_main_window_mount_view(qtbot, mock_ui_state): with (