Files
AareDAQ/tests/unit/gui/test_monochromator_panel.py
duan_jandClaude Fable 5 8f91f1ed2e feat: fast shutter open/close row in Beamline setup
Status flag on the left (same rich-text scheme as the status bar,
theme-aware via set_theme), Open/Close buttons on the right, wired
to the same daq.open_shutter/close_shutter slots staff-gated in
main_window.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-17 15:34:58 +02:00

39 lines
1.4 KiB
Python

from aare.gui.panels.monochromator_panel import MonochromatorPanel
def test_current_energy_readout(qtbot, daq_status_factory):
panel = MonochromatorPanel()
qtbot.addWidget(panel)
status = 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()
qtbot.addWidget(panel)
# Placeholder until the first DAQ tick.
assert panel.shutter_status_label.text() == "Fast Shutter: —"
status = daq_status_factory()
panel.update_daq_status(status)
assert "Closed" in panel.shutter_status_label.text()
status.bl = status.bl.model_copy(update={"shutter_open": True})
panel.update_daq_status(status)
assert "Open" in panel.shutter_status_label.text()
# Buttons relay to the same DAQ signals the status-bar menu uses.
with qtbot.waitSignal(panel.open_shutter, timeout=1000):
panel.open_shutter_button.click()
with qtbot.waitSignal(panel.close_shutter, timeout=1000):
panel.close_shutter_button.click()