mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-05-05 06:16:32 +02:00
fix: address code review feedback - clean up test and add error handling
Agent-Logs-Url: https://github.com/bec-project/bec_widgets/sessions/872a29f8-acdf-42e5-94b9-bad871aef4a0 Co-authored-by: wyzula-jan <133381102+wyzula-jan@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9b070f2031
commit
5c29be4383
@@ -400,7 +400,11 @@ class BECDockArea(DockAreaWidget):
|
||||
_build_menu("menu_utils", "Add Utils ", util_actions)
|
||||
|
||||
# Build plugin widget menu (only shown when plugin widgets are available)
|
||||
plugin_widgets_dict = get_all_plugin_widgets().as_dict()
|
||||
try:
|
||||
plugin_widgets_dict = get_all_plugin_widgets().as_dict()
|
||||
except Exception:
|
||||
logger.warning("Failed to load plugin widgets for toolbar menu.", exc_info=True)
|
||||
plugin_widgets_dict = {}
|
||||
plugin_actions: dict[str, tuple[str, str, str]] = {
|
||||
widget_name: (
|
||||
getattr(widget_cls, "ICON_NAME", "widgets"),
|
||||
|
||||
@@ -1043,7 +1043,6 @@ class TestToolbarFunctionality:
|
||||
def test_plugin_menu_shown_when_plugins_available(self, qtbot, mocked_client):
|
||||
"""Test that the plugin menu is shown when plugin widgets are available."""
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.utils.plugin_utils import BECClassContainer, BECClassInfo
|
||||
from qtpy.QtWidgets import QWidget as _QWidget
|
||||
|
||||
class FakePluginWidget(BECWidget, _QWidget):
|
||||
@@ -1053,15 +1052,9 @@ class TestToolbarFunctionality:
|
||||
def __init__(self, parent=None, **kwargs):
|
||||
super().__init__(parent=parent, **kwargs)
|
||||
|
||||
container = BECClassContainer(
|
||||
[BECClassInfo(name="FakePluginWidget", module="fake", file="fake.py", obj=FakePluginWidget)]
|
||||
)
|
||||
|
||||
with patch(
|
||||
"bec_widgets.widgets.containers.dock_area.dock_area.get_all_plugin_widgets"
|
||||
) as mock_plugins:
|
||||
mock_plugins.return_value = container
|
||||
# Make as_dict() return our fake widget
|
||||
container_mock = MagicMock()
|
||||
container_mock.as_dict.return_value = {"FakePluginWidget": FakePluginWidget}
|
||||
mock_plugins.return_value = container_mock
|
||||
|
||||
Reference in New Issue
Block a user