mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-05-13 01:55:46 +02:00
fix(scan_control): restore scan parameters from history are fetched on demand with button
This commit is contained in:
@@ -503,12 +503,42 @@ def test_changing_scans_remember_parameters(scan_control, mocked_client):
|
||||
assert grid_kwargs["burst_at_each_point"] == kwargs["burst_at_each_point"]
|
||||
|
||||
|
||||
def test_scan_selection_does_not_fetch_last_scan_parameters(
|
||||
scan_control, mocked_client, monkeypatch
|
||||
):
|
||||
xread = MagicMock(wraps=mocked_client.connector.xread)
|
||||
monkeypatch.setattr(mocked_client.connector, "xread", xread)
|
||||
|
||||
scan_control.comboBox_scan_selection.setCurrentText("grid_scan")
|
||||
|
||||
xread.assert_not_called()
|
||||
|
||||
|
||||
def test_restore_last_scan_parameters_button_fetches_on_demand(
|
||||
scan_control, mocked_client, qtbot, monkeypatch
|
||||
):
|
||||
scan_control.comboBox_scan_selection.setCurrentText("line_scan")
|
||||
xread = MagicMock(wraps=mocked_client.connector.xread)
|
||||
monkeypatch.setattr(mocked_client.connector, "xread", xread)
|
||||
|
||||
qtbot.mouseClick(scan_control.last_scan_button, Qt.LeftButton)
|
||||
|
||||
xread.assert_called_once_with(
|
||||
MessageEndpoints.scan_history(), from_start=True, user_id=scan_control.object_name
|
||||
)
|
||||
args, kwargs = scan_control.get_scan_parameters(bec_object=False)
|
||||
assert args == ["samx", 0.0, 2.0]
|
||||
assert kwargs["steps"] == 10
|
||||
assert kwargs["relative"] is False
|
||||
assert kwargs["exp_time"] == 2
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Unreliable - GH issue #1134")
|
||||
def test_get_scan_parameters_from_redis(scan_control, mocked_client):
|
||||
scan_name = "line_scan"
|
||||
scan_control.comboBox_scan_selection.setCurrentText(scan_name)
|
||||
|
||||
scan_control.toggle.checked = True
|
||||
scan_control.last_scan_button.click()
|
||||
|
||||
args, kwargs = scan_control.get_scan_parameters(bec_object=False)
|
||||
|
||||
@@ -605,7 +635,7 @@ def test_restore_parameters_with_fewer_arg_bundles(scan_control, qtbot):
|
||||
assert scan_control.arg_box.count_arg_rows() == 3
|
||||
|
||||
# Trigger restore of parameters from history
|
||||
scan_control.toggle.checked = True
|
||||
scan_control.last_scan_button.click()
|
||||
qtbot.wait(200)
|
||||
|
||||
# After restore, arg_box should have only one bundle (the history size)
|
||||
|
||||
Reference in New Issue
Block a user