mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-03-04 16:02:51 +01:00
fix(device-manager): fix minor icon synchronization bugs
This commit is contained in:
@@ -531,6 +531,8 @@ class DeviceManagerDisplayWidget(DockAreaWidget):
|
||||
self.ophyd_test_view.change_device_configs(
|
||||
[cfg for cfg, _, _, _ in devices_to_update], added=False, skip_validation=True
|
||||
)
|
||||
# Config is in sync with BEC, so we update the state
|
||||
self.device_table_view.device_config_in_sync_with_redis.emit(True)
|
||||
|
||||
@SafeSlot()
|
||||
def _save_to_disk_action(self):
|
||||
|
||||
@@ -978,6 +978,8 @@ class DeviceTable(BECWidget, QtWidgets.QWidget):
|
||||
logger.warning(f"Device {cfg.get('name')} not found in table for session update.")
|
||||
continue
|
||||
self._update_device_row_status(row, config_status, connection_status)
|
||||
in_sync_with_redis = self._is_config_in_sync_with_redis()
|
||||
self.device_config_in_sync_with_redis.emit(in_sync_with_redis)
|
||||
self.table.setSortingEnabled(True)
|
||||
self.set_busy(False, text="")
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
# pylint: disable=protected-access,redefined-outer-name
|
||||
|
||||
from typing import Any
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@@ -682,3 +683,35 @@ class TestDeviceManagerView:
|
||||
"rerun_validation"
|
||||
].action.action.triggered.emit()
|
||||
assert len(mock_change_configs.call_args[0][0]) == 1
|
||||
|
||||
def test_update_validation_icons_after_upload(
|
||||
self,
|
||||
device_manager_display_widget: DeviceManagerDisplayWidget,
|
||||
device_configs: list[dict[str, Any]],
|
||||
):
|
||||
"""Test that validation icons are updated after uploading to Redis."""
|
||||
dm_view = device_manager_display_widget
|
||||
|
||||
# Add device configs to the table
|
||||
dm_view.device_table_view.add_device_configs(device_configs)
|
||||
# Update the device manager devices to match what's in the table
|
||||
dm_view.client.device_manager.devices = {cfg["name"]: cfg for cfg in device_configs}
|
||||
|
||||
# Simulate callback
|
||||
dm_view._update_validation_icons_after_upload()
|
||||
|
||||
# Get validation results from the table
|
||||
validation_results = dm_view.device_table_view.get_validation_results()
|
||||
# Check that all devices are connected and status is updated
|
||||
for dev_name, (cfg, _, connection_status) in validation_results.items():
|
||||
assert cfg in device_configs
|
||||
assert connection_status == ConnectionStatus.CONNECTED.value
|
||||
|
||||
# Check that no devices are in ophyd_validation widget
|
||||
# Those should be all cleared after upload
|
||||
cfgs = dm_view.ophyd_test_view.get_device_configs()
|
||||
assert len(cfgs) == 0
|
||||
|
||||
# Check that upload config button is disabled
|
||||
action = dm_view.toolbar.components.get_action("update_config_redis")
|
||||
assert action.action.isEnabled() is False
|
||||
|
||||
Reference in New Issue
Block a user