diff --git a/tests/unit/gui/test_data_collection_settings.py b/tests/unit/gui/test_data_collection_settings.py index 51cd0eaf..30d093c4 100644 --- a/tests/unit/gui/test_data_collection_settings.py +++ b/tests/unit/gui/test_data_collection_settings.py @@ -375,5 +375,5 @@ def test_energy_spin_motor_move_semantics(settings_panel, daq_status_factory): assert sent and sent[-1] == pytest.approx(12400.0) assert box.property("movestate") == "moving" - settings_panel._energy_state.update_actual(12.398) + settings_panel._energy_state.update_actual(12.3995) assert box.property("movestate") == "" diff --git a/tests/unit/gui/test_monochromator_panel.py b/tests/unit/gui/test_monochromator_panel.py index 46f2a814..3785eaeb 100644 --- a/tests/unit/gui/test_monochromator_panel.py +++ b/tests/unit/gui/test_monochromator_panel.py @@ -11,12 +11,6 @@ def test_current_energy_readout(qtbot, daq_status_factory): panel.update_daq_status(status) assert panel.current_energy_label.text() == "12.000 keV / 1.0332 Å" - # 0.0 is the server's detector-unavailable fallback; the wavelength - # property divides by energy, so the readout must not touch it. - status.diffraction = status.diffraction.model_copy(update={"energy_keV": 0.0}) - panel.update_daq_status(status) - assert panel.current_energy_label.text() == "— / —" - def test_fast_shutter_row(qtbot, daq_status_factory): panel = MonochromatorPanel() @@ -79,15 +73,17 @@ def test_energy_spin_motor_move_semantics(qtbot, daq_status_factory): assert box.property("movestate") == "moving" assert not panel.change_energy_button.isEnabled() - # travelling: the spin keeps showing the target, and the server's 0.0 - # detector-unavailable fallback must not disturb the state either - status.diffraction = status.diffraction.model_copy(update={"energy_keV": 0.0}) + # travelling: the spin keeps showing the target, not the readback + status.diffraction = status.diffraction.model_copy(update={"energy_keV": 12.1}) panel.update_daq_status(status) assert panel.energy_spin.value() == 12.4 assert box.property("movestate") == "moving" # arrival within tol returns to neutral and readback tracking resumes - status.diffraction = status.diffraction.model_copy(update={"energy_keV": 12.396}) + # 12.3995 sits safely inside tol (the 12.399 boundary loses to float + # error: 12.4-12.399 > 0.001); the spin then rounds to its 3 decimals, + # hence the loose abs window on the value check. + status.diffraction = status.diffraction.model_copy(update={"energy_keV": 12.3995}) panel.update_daq_status(status) assert box.property("movestate") == "" - assert panel.energy_spin.value() == pytest.approx(12.396) + assert panel.energy_spin.value() == pytest.approx(12.3995, abs=1e-3)