mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-06-05 21:08:40 +02:00
Wip BL states adding dialog
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from bec_lib import messages
|
||||
|
||||
from bec_widgets.utils.toolbars.toolbar import ModularToolBar
|
||||
from bec_widgets.widgets.services.beamline_states.beamline_state_pill import (
|
||||
BeamlineStateList,
|
||||
AddBeamlineStateDialog,
|
||||
BeamlineStateManager,
|
||||
BeamlineStatePill,
|
||||
)
|
||||
|
||||
@@ -37,8 +39,8 @@ def test_beamline_state_pill_ignores_other_states(qtbot, mocked_client):
|
||||
assert widget.toolTip() == "No state information available."
|
||||
|
||||
|
||||
def test_beamline_state_list_adds_and_removes_pills(qtbot, mocked_client):
|
||||
widget = BeamlineStateList(client=mocked_client)
|
||||
def test_beamline_state_manager_adds_and_removes_pills(qtbot, mocked_client):
|
||||
widget = BeamlineStateManager(client=mocked_client)
|
||||
qtbot.addWidget(widget)
|
||||
|
||||
widget.update_available_states(
|
||||
@@ -77,3 +79,113 @@ def test_beamline_state_list_adds_and_removes_pills(qtbot, mocked_client):
|
||||
)
|
||||
|
||||
assert sorted(widget._state_pills) == ["limits"]
|
||||
|
||||
|
||||
def test_beamline_state_manager_filters_states(qtbot, mocked_client):
|
||||
widget = BeamlineStateManager(client=mocked_client)
|
||||
qtbot.addWidget(widget)
|
||||
|
||||
widget.update_available_states(
|
||||
{
|
||||
"states": [
|
||||
{
|
||||
"name": "shutter_open",
|
||||
"title": "Shutter",
|
||||
"state_type": "ShutterState",
|
||||
"parameters": {"device": "samy"},
|
||||
},
|
||||
{
|
||||
"name": "limits",
|
||||
"title": "Limits",
|
||||
"state_type": "DeviceWithinLimitsState",
|
||||
"parameters": {"device": "samx"},
|
||||
},
|
||||
]
|
||||
},
|
||||
{},
|
||||
)
|
||||
|
||||
assert isinstance(widget._toolbar, ModularToolBar)
|
||||
|
||||
widget._selected_state_names = {"limits"}
|
||||
widget._apply_filters()
|
||||
|
||||
assert not widget._hidden_summary.isHidden()
|
||||
assert "1 state is hidden" in widget._hidden_summary.text()
|
||||
assert widget._state_pills["limits"].parent() is widget._content
|
||||
assert widget._state_pills["shutter_open"].parent() is widget._hidden_content
|
||||
|
||||
widget._toggle_hidden_states(True)
|
||||
|
||||
assert not widget._hidden_content.isHidden()
|
||||
|
||||
|
||||
def test_beamline_state_manager_filters_devices(qtbot, mocked_client):
|
||||
widget = BeamlineStateManager(client=mocked_client)
|
||||
qtbot.addWidget(widget)
|
||||
|
||||
widget.update_available_states(
|
||||
{
|
||||
"states": [
|
||||
{
|
||||
"name": "samx_limits",
|
||||
"title": "samx",
|
||||
"state_type": "DeviceWithinLimitsState",
|
||||
"parameters": {"device": "samx"},
|
||||
},
|
||||
{
|
||||
"name": "samy_limits",
|
||||
"title": "samy",
|
||||
"state_type": "DeviceWithinLimitsState",
|
||||
"parameters": {"device": "samy"},
|
||||
},
|
||||
]
|
||||
},
|
||||
{},
|
||||
)
|
||||
|
||||
widget._device_filter_text = "samx"
|
||||
widget._apply_filters()
|
||||
|
||||
assert not widget._hidden_summary.isHidden()
|
||||
assert "1 state is hidden" in widget._hidden_summary.text()
|
||||
assert widget._available_devices() == ["samx", "samy"]
|
||||
|
||||
|
||||
def test_add_beamline_state_dialog_uses_device_signal_widgets_and_normalizes_name(
|
||||
qtbot, mocked_client
|
||||
):
|
||||
dialog = AddBeamlineStateDialog(client=mocked_client)
|
||||
qtbot.addWidget(dialog)
|
||||
|
||||
dialog._type_combo.setCurrentIndex(1)
|
||||
dialog._name.setText("samx-limits")
|
||||
dialog._title.setText("samx-limits-15")
|
||||
dialog._device.set_device("samx")
|
||||
dialog._signal.set_signal("samx")
|
||||
dialog._high_limit.setValue(15.0)
|
||||
|
||||
config = dialog.config()
|
||||
|
||||
assert config.name == "samx_limits"
|
||||
assert config.title == "samx-limits-15"
|
||||
assert config.device == "samx"
|
||||
assert config.signal == "samx"
|
||||
assert config.low_limit == 0.0
|
||||
assert config.high_limit == 15.0
|
||||
|
||||
|
||||
def test_add_beamline_state_dialog_generates_name_only_after_valid_device_selection(
|
||||
qtbot, mocked_client
|
||||
):
|
||||
dialog = AddBeamlineStateDialog(client=mocked_client)
|
||||
qtbot.addWidget(dialog)
|
||||
|
||||
dialog._type_combo.setCurrentIndex(1)
|
||||
dialog._device.setCurrentText("s")
|
||||
|
||||
assert dialog._name.text() == ""
|
||||
|
||||
dialog._device.set_device("samx")
|
||||
|
||||
assert dialog._name.text() == "samx_limits"
|
||||
|
||||
Reference in New Issue
Block a user