mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-10-11 16:50:33 +02:00
fix(tests): client_mocks moved inside the package, imports for tests adjusted
This commit is contained in:
@@ -159,7 +159,9 @@ when practical. Create widgets with `create_widget(...)` from `tests/unit_tests/
|
||||
registers the widget with `qtbot` so it is closed at test end; the autouse conftest fixtures handle the
|
||||
rest of the teardown (dispatcher disconnect, singleton resets) and fail the test if any top-level
|
||||
widget is left open. Before adding a new fixture, check for reusable fixtures in
|
||||
`tests/unit_tests/conftest.py` and fake devices in `bec_widgets/tests/fake_devices.py`.
|
||||
`tests/unit_tests/conftest.py` and the packaged helpers in `bec_widgets/tests/`: `client_mocks.py`
|
||||
(`mocked_client`, `mocked_client_with_dap`), `fake_devices.py`, and `utils.py`, which holds the
|
||||
bodies of the autouse fixtures so plugin repositories can reuse them.
|
||||
|
||||
Mock BEC, Redis, and hardware in unit tests. Reuse existing helpers such as `FakeDevice`,
|
||||
`FakePositioner`, `DMMock`, and the shared autouse fixtures rather than rolling your own.
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
QTimer replacement used to detect timers that are still running at the end of a test.
|
||||
|
||||
This module deliberately imports nothing but Qt and pytest-qt: it has to be patched over
|
||||
``qtpy.QtCore.QTimer`` before any module that does ``from qtpy.QtCore import QTimer`` is imported.
|
||||
"""
|
||||
|
||||
import traceback
|
||||
|
||||
from pytestqt.exceptions import TimeoutError as QtBotTimeoutError
|
||||
from qtpy.QtCore import QTimer
|
||||
|
||||
|
||||
class TestableQTimer(QTimer):
|
||||
"""
|
||||
QTimer that records every instance, so that timers left running after a test can be reported.
|
||||
Patch it over ``qtpy.QtCore.QTimer`` before the widgets under test are imported.
|
||||
"""
|
||||
|
||||
_instances: list[tuple[QTimer, str, str]] = []
|
||||
_current_test_name: str = ""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
tb = traceback.format_stack()
|
||||
init_line = list(filter(lambda msg: "QTimer(" in msg, tb))[-1]
|
||||
TestableQTimer._instances.append((self, TestableQTimer._current_test_name, init_line))
|
||||
|
||||
@classmethod
|
||||
def check_all_stopped(cls, qtbot):
|
||||
def _is_done_or_deleted(t: QTimer):
|
||||
try:
|
||||
return not t.isActive()
|
||||
except RuntimeError as e:
|
||||
return "already deleted" in e.args[0]
|
||||
|
||||
def _format_timers(timers: list[tuple[QTimer, str, str]]):
|
||||
return "\n".join(
|
||||
f"Timer: {t[0]}\n in test: {t[1]}\n created at:{t[2]}" for t in timers
|
||||
)
|
||||
|
||||
try:
|
||||
qtbot.waitUntil(
|
||||
lambda: all(_is_done_or_deleted(timer) for timer, _, _ in cls._instances)
|
||||
)
|
||||
except QtBotTimeoutError as exc:
|
||||
active_timers = list(filter(lambda t: t[0].isActive(), cls._instances))
|
||||
(t.stop() for t, _, _ in cls._instances)
|
||||
raise TimeoutError(
|
||||
f"Failed to stop all timers:\n{_format_timers(active_timers)}"
|
||||
) from exc
|
||||
cls._instances = []
|
||||
@@ -0,0 +1,137 @@
|
||||
"""
|
||||
Shared bodies of the autouse fixtures of the bec_widgets unit tests.
|
||||
|
||||
The ``*_fixture`` generators are meant to be wrapped in local fixtures, so that plugin repositories
|
||||
can run their widget tests against the same mocked BEC client and leak checks, e.g.::
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def bec_dispatcher(threads_check):
|
||||
yield from bec_widgets.tests.utils.bec_dispatcher_fixture()
|
||||
"""
|
||||
|
||||
from unittest import mock
|
||||
from unittest.mock import patch
|
||||
|
||||
import fakeredis
|
||||
from bec_lib import service_config
|
||||
from bec_lib.client import BECClient
|
||||
from bec_qthemes import apply_theme
|
||||
from bec_qthemes._theme import Theme
|
||||
from pytestqt.exceptions import TimeoutError as QtBotTimeoutError
|
||||
from qtpy.QtCore import QEvent, QEventLoop
|
||||
from qtpy.QtWidgets import QApplication
|
||||
|
||||
from bec_widgets.tests.fake_devices import DEVICES, DMMock
|
||||
from bec_widgets.utils import bec_dispatcher as bec_dispatcher_module
|
||||
from bec_widgets.utils import error_popups
|
||||
from bec_widgets.utils.bec_dispatcher import QtRedisConnector
|
||||
from bec_widgets.utils.rpc_register import RPCRegister
|
||||
|
||||
|
||||
def process_all_deferred_deletes(qapp):
|
||||
qapp.sendPostedEvents(None, QEvent.DeferredDelete)
|
||||
qapp.processEvents(QEventLoop.AllEvents)
|
||||
|
||||
|
||||
def qapplication_fixture(qtbot, request, testable_qtimer_class):
|
||||
"""
|
||||
Reset the application to the light theme, then check after the test that all timers are
|
||||
stopped and all top-level widgets are closed. The checks are skipped for failed tests, which
|
||||
requires a ``pytest_runtest_makereport`` hook that stores ``item.stash["failed"]``.
|
||||
"""
|
||||
qapp = QApplication.instance()
|
||||
process_all_deferred_deletes(qapp)
|
||||
|
||||
if (
|
||||
not hasattr(qapp, "theme")
|
||||
or not isinstance(qapp.theme, Theme)
|
||||
or qapp.theme.theme != "light"
|
||||
):
|
||||
apply_theme("light")
|
||||
qapp.processEvents()
|
||||
|
||||
yield
|
||||
|
||||
# Imported here so that the test session can select the ophyd control layer before ophyd loads
|
||||
from ophyd._dummy_shim import _dispatcher
|
||||
|
||||
from bec_widgets.widgets.editors.bec_console.bec_console import _bec_console_registry
|
||||
|
||||
# stop pyepics dispatcher for leaking tests
|
||||
_dispatcher.stop()
|
||||
_bec_console_registry.clear()
|
||||
process_all_deferred_deletes(qapp)
|
||||
# if the test failed, we don't want to check for open widgets as
|
||||
# it simply pollutes the output
|
||||
if request.node.stash._storage.get("failed"):
|
||||
print("Test failed, skipping cleanup checks")
|
||||
return
|
||||
bec_dispatcher = bec_dispatcher_module.BECDispatcher()
|
||||
bec_dispatcher.stop_cli_server()
|
||||
|
||||
testable_qtimer_class.check_all_stopped(qtbot)
|
||||
qapp.processEvents()
|
||||
if hasattr(qapp, "os_listener") and qapp.os_listener:
|
||||
qapp.removeEventFilter(qapp.os_listener)
|
||||
try:
|
||||
qtbot.waitUntil(lambda: qapp.topLevelWidgets() == [])
|
||||
except QtBotTimeoutError as exc:
|
||||
raise TimeoutError(f"Failed to close all widgets: {qapp.topLevelWidgets()}") from exc
|
||||
|
||||
|
||||
def rpc_register_fixture():
|
||||
"""Provide the RPCRegister singleton and reset it after the test."""
|
||||
yield RPCRegister()
|
||||
RPCRegister.reset_singleton()
|
||||
|
||||
|
||||
_REDIS_CONN: QtRedisConnector | None = None
|
||||
|
||||
|
||||
def global_mock_qt_redis_connector(*_, **__):
|
||||
global _REDIS_CONN
|
||||
if _REDIS_CONN is None:
|
||||
_REDIS_CONN = QtRedisConnector(bootstrap="localhost:1", redis_cls=fakeredis.FakeRedis)
|
||||
return _REDIS_CONN
|
||||
|
||||
|
||||
def mock_client(*_, **__):
|
||||
"""Create a BECClient on a shared fakeredis connector, populated with the fake DEVICES."""
|
||||
with (
|
||||
patch("bec_lib.client.DeviceManagerBase", DMMock),
|
||||
patch("bec_lib.client.DAPPlugins"),
|
||||
patch("bec_lib.client.Scans"),
|
||||
patch("bec_lib.client.ScanManager"),
|
||||
patch("bec_lib.bec_service.BECAccess"),
|
||||
):
|
||||
client = BECClient(
|
||||
config=service_config.ServiceConfig(config={"redis": {"host": "localhost", "port": 1}}),
|
||||
connector_cls=global_mock_qt_redis_connector,
|
||||
)
|
||||
client.start()
|
||||
client.device_manager.add_devices(DEVICES)
|
||||
return client
|
||||
|
||||
|
||||
def bec_dispatcher_fixture():
|
||||
"""
|
||||
Provide a BECDispatcher backed by :func:`mock_client` and tear it down after the test. The
|
||||
wrapping fixture should depend on bec_lib's ``threads_check`` so that the thread check runs
|
||||
after the client is shut down.
|
||||
"""
|
||||
with mock.patch.object(bec_dispatcher_module, "BECClient", mock_client):
|
||||
bec_dispatcher = bec_dispatcher_module.BECDispatcher()
|
||||
yield bec_dispatcher
|
||||
bec_dispatcher.disconnect_all()
|
||||
# clean BEC client
|
||||
bec_dispatcher.client.shutdown()
|
||||
# stop the cli server
|
||||
bec_dispatcher.stop_cli_server()
|
||||
# reinitialize singleton for next test
|
||||
bec_dispatcher_module.BECDispatcher.reset_singleton()
|
||||
|
||||
|
||||
def clean_singleton_fixture():
|
||||
"""Drop the error popup singleton before the test."""
|
||||
error_popups._popup_utility_instance = None
|
||||
yield
|
||||
+1
-40
@@ -1,46 +1,7 @@
|
||||
import traceback
|
||||
|
||||
import pytest
|
||||
import qtpy.QtCore
|
||||
from pytestqt.exceptions import TimeoutError as QtBotTimeoutError
|
||||
from qtpy.QtCore import QTimer
|
||||
|
||||
|
||||
class TestableQTimer(QTimer):
|
||||
_instances: list[tuple[QTimer, str, str]] = []
|
||||
_current_test_name: str = ""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
tb = traceback.format_stack()
|
||||
init_line = list(filter(lambda msg: "QTimer(" in msg, tb))[-1]
|
||||
TestableQTimer._instances.append((self, TestableQTimer._current_test_name, init_line))
|
||||
|
||||
@classmethod
|
||||
def check_all_stopped(cls, qtbot):
|
||||
def _is_done_or_deleted(t: QTimer):
|
||||
try:
|
||||
return not t.isActive()
|
||||
except RuntimeError as e:
|
||||
return "already deleted" in e.args[0]
|
||||
|
||||
def _format_timers(timers: list[tuple[QTimer, str, str]]):
|
||||
return "\n".join(
|
||||
f"Timer: {t[0]}\n in test: {t[1]}\n created at:{t[2]}" for t in timers
|
||||
)
|
||||
|
||||
try:
|
||||
qtbot.waitUntil(
|
||||
lambda: all(_is_done_or_deleted(timer) for timer, _, _ in cls._instances)
|
||||
)
|
||||
except QtBotTimeoutError as exc:
|
||||
active_timers = list(filter(lambda t: t[0].isActive(), cls._instances))
|
||||
(t.stop() for t, _, _ in cls._instances)
|
||||
raise TimeoutError(
|
||||
f"Failed to stop all timers:\n{_format_timers(active_timers)}"
|
||||
) from exc
|
||||
cls._instances = []
|
||||
|
||||
from bec_widgets.tests.testable_qtimer import TestableQTimer
|
||||
|
||||
# To support 'from qtpy.QtCore import QTimer' syntax we just replace this completely for the test session
|
||||
# see: https://docs.python.org/3/library/unittest.mock.html#where-to-patch
|
||||
|
||||
@@ -2,9 +2,9 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.containers.dock_area.dock_area import BECDockArea
|
||||
from bec_widgets.widgets.plots.waveform.waveform import Waveform
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -5,29 +5,15 @@ import os
|
||||
os.environ.setdefault("OPHYD_CONTROL_LAYER", "dummy")
|
||||
import json
|
||||
import time
|
||||
from unittest import mock
|
||||
from unittest.mock import patch
|
||||
|
||||
import fakeredis
|
||||
import h5py
|
||||
import numpy as np
|
||||
import pytest
|
||||
from bec_lib import messages, service_config
|
||||
from bec_lib.bec_service import messages
|
||||
from bec_lib.client import BECClient
|
||||
from bec_lib import messages
|
||||
from bec_lib.messages import _StoredDataInfo
|
||||
from bec_qthemes import apply_theme
|
||||
from bec_qthemes._theme import Theme
|
||||
from ophyd._dummy_shim import _dispatcher
|
||||
from pytestqt.exceptions import TimeoutError as QtBotTimeoutError
|
||||
from qtpy.QtCore import QEvent, QEventLoop
|
||||
from qtpy.QtWidgets import QApplication, QMessageBox
|
||||
from qtpy.QtWidgets import QMessageBox
|
||||
|
||||
from bec_widgets.tests.fake_devices import DEVICES, DMMock
|
||||
from bec_widgets.utils import bec_dispatcher as bec_dispatcher_module
|
||||
from bec_widgets.utils import error_popups
|
||||
from bec_widgets.utils.bec_dispatcher import QtRedisConnector
|
||||
from bec_widgets.utils.rpc_register import RPCRegister
|
||||
from bec_widgets.tests import utils as test_utils
|
||||
from bec_widgets.widgets.containers.main_window.addons.notification_center.notification_banner import (
|
||||
BECNotificationBroker,
|
||||
)
|
||||
@@ -46,96 +32,19 @@ def pytest_runtest_makereport(item, call):
|
||||
item.stash["failed"] = rep.failed
|
||||
|
||||
|
||||
def process_all_deferred_deletes(qapp):
|
||||
qapp.sendPostedEvents(None, QEvent.DeferredDelete)
|
||||
qapp.processEvents(QEventLoop.AllEvents)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def qapplication(qtbot, request, testable_qtimer_class): # pylint: disable=unused-argument
|
||||
qapp = QApplication.instance()
|
||||
process_all_deferred_deletes(qapp)
|
||||
|
||||
if (
|
||||
not hasattr(qapp, "theme")
|
||||
or not isinstance(qapp.theme, Theme)
|
||||
or qapp.theme.theme != "light"
|
||||
):
|
||||
apply_theme("light")
|
||||
qapp.processEvents()
|
||||
|
||||
yield
|
||||
|
||||
# if the test failed, we don't want to check for open widgets as
|
||||
# it simply pollutes the output
|
||||
# stop pyepics dispatcher for leaking tests
|
||||
|
||||
_dispatcher.stop()
|
||||
from bec_widgets.widgets.editors.bec_console.bec_console import _bec_console_registry
|
||||
|
||||
_bec_console_registry.clear()
|
||||
process_all_deferred_deletes(qapp)
|
||||
if request.node.stash._storage.get("failed"):
|
||||
print("Test failed, skipping cleanup checks")
|
||||
return
|
||||
bec_dispatcher = bec_dispatcher_module.BECDispatcher()
|
||||
bec_dispatcher.stop_cli_server()
|
||||
|
||||
testable_qtimer_class.check_all_stopped(qtbot)
|
||||
qapp.processEvents()
|
||||
if hasattr(qapp, "os_listener") and qapp.os_listener:
|
||||
qapp.removeEventFilter(qapp.os_listener)
|
||||
try:
|
||||
qtbot.waitUntil(lambda: qapp.topLevelWidgets() == [])
|
||||
except QtBotTimeoutError as exc:
|
||||
raise TimeoutError(f"Failed to close all widgets: {qapp.topLevelWidgets()}") from exc
|
||||
yield from test_utils.qapplication_fixture(qtbot, request, testable_qtimer_class)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def rpc_register():
|
||||
yield RPCRegister()
|
||||
RPCRegister.reset_singleton()
|
||||
|
||||
|
||||
_REDIS_CONN: QtRedisConnector | None = None
|
||||
|
||||
|
||||
def global_mock_qt_redis_connector(*_, **__):
|
||||
global _REDIS_CONN
|
||||
if _REDIS_CONN is None:
|
||||
_REDIS_CONN = QtRedisConnector(bootstrap="localhost:1", redis_cls=fakeredis.FakeRedis)
|
||||
return _REDIS_CONN
|
||||
|
||||
|
||||
def mock_client(*_, **__):
|
||||
with (
|
||||
patch("bec_lib.client.DeviceManagerBase", DMMock),
|
||||
patch("bec_lib.client.DAPPlugins"),
|
||||
patch("bec_lib.client.Scans"),
|
||||
patch("bec_lib.client.ScanManager"),
|
||||
patch("bec_lib.bec_service.BECAccess"),
|
||||
):
|
||||
client = BECClient(
|
||||
config=service_config.ServiceConfig(config={"redis": {"host": "localhost", "port": 1}}),
|
||||
connector_cls=global_mock_qt_redis_connector,
|
||||
)
|
||||
client.start()
|
||||
client.device_manager.add_devices(DEVICES)
|
||||
return client
|
||||
yield from test_utils.rpc_register_fixture()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def bec_dispatcher(threads_check): # pylint: disable=unused-argument
|
||||
with mock.patch.object(bec_dispatcher_module, "BECClient", mock_client):
|
||||
bec_dispatcher = bec_dispatcher_module.BECDispatcher()
|
||||
yield bec_dispatcher
|
||||
bec_dispatcher.disconnect_all()
|
||||
# clean BEC client
|
||||
bec_dispatcher.client.shutdown()
|
||||
# stop the cli server
|
||||
bec_dispatcher.stop_cli_server()
|
||||
# reinitialize singleton for next test
|
||||
bec_dispatcher_module.BECDispatcher.reset_singleton()
|
||||
yield from test_utils.bec_dispatcher_fixture()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -147,7 +56,7 @@ def notification_broker_reset(bec_dispatcher): # pylint: disable=unused-argumen
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_singleton():
|
||||
error_popups._popup_utility_instance = None
|
||||
yield from test_utils.clean_singleton_fixture()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
||||
@@ -4,10 +4,9 @@ from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.control.buttons.button_abort.button_abort import AbortButton
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def abort_button(qtbot, mocked_client):
|
||||
|
||||
@@ -3,13 +3,13 @@ from unittest.mock import MagicMock
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.waveform.utils.alignment_controller import (
|
||||
AlignmentContext,
|
||||
WaveformAlignmentController,
|
||||
)
|
||||
from bec_widgets.widgets.plots.waveform.utils.alignment_panel import WaveformAlignmentPanel
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
from .test_waveform import make_alignment_fit_summary
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.waveform.utils.alignment_panel import WaveformAlignmentPanel
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import pytest
|
||||
from qtpy.QtWidgets import QDoubleSpinBox, QLineEdit
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.plot_base import PlotBase
|
||||
from bec_widgets.widgets.plots.setting_menus.axis_settings import AxisSettings
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
from tests.unit_tests.conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from bec_lib import bl_states, messages
|
||||
from qtpy.QtCore import QCoreApplication, QEvent, Qt
|
||||
from qtpy.QtWidgets import QDialog, QMessageBox, QStyleOptionViewItem
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.eliding_label import ElidingLabel
|
||||
from bec_widgets.utils.toolbars.toolbar import ModularToolBar
|
||||
from bec_widgets.utils.widget_io import WidgetIO
|
||||
@@ -12,7 +13,6 @@ from bec_widgets.widgets.services.beamline_states.beamline_state_manager import
|
||||
from bec_widgets.widgets.services.beamline_states.beamline_state_pill import BeamlineStatePill
|
||||
from bec_widgets.widgets.services.beamline_states.dialogs import AddBeamlineStateDialog
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ import pytest
|
||||
from qtpy.QtCore import QObject
|
||||
from qtpy.QtWidgets import QApplication, QWidget
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.bec_connector import BECConnector
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.utils.error_popups import SafeProperty
|
||||
from bec_widgets.utils.error_popups import SafeSlot as Slot
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
class BECConnectorQObject(BECConnector, QObject): ...
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from qtpy.QtTest import QTest
|
||||
from qtpy.QtWidgets import QApplication, QWidget
|
||||
|
||||
import bec_widgets.widgets.editors.bec_console.bec_console as bec_console_module
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.editors.bec_console.bec_console import (
|
||||
BecConsole,
|
||||
BECShell,
|
||||
@@ -16,8 +17,6 @@ from bec_widgets.widgets.editors.bec_console.bec_console import (
|
||||
)
|
||||
from bec_widgets.widgets.utility.bec_term.qtermwidget_wrapper import BecQTerm
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
def process_deferred_deletes():
|
||||
app = QApplication.instance()
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import pytest
|
||||
from bec_lib import messages
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.services.bec_queue.bec_queue import BECQueue
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bec_queue_msg_full():
|
||||
|
||||
@@ -4,13 +4,12 @@ from unittest import mock
|
||||
import pytest
|
||||
from bec_lib.messages import BECStatus, ServiceInfo, ServiceMetricMessage, StatusMessage
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.services.bec_status_box.bec_status_box import (
|
||||
BECServiceInfoContainer,
|
||||
BECStatusBox,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def service_status_fixture():
|
||||
|
||||
@@ -4,11 +4,10 @@ from bec_lib.endpoints import MessageEndpoints
|
||||
from qtpy.QtCore import QEvent, QObject
|
||||
from qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.utils.rpc_register import RPCRegister
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
class LifecycleWidget(BECWidget, QWidget):
|
||||
def __init__(self, parent=None, client=None, **kwargs):
|
||||
|
||||
@@ -3,10 +3,9 @@ import pytest
|
||||
from qtpy.QtWidgets import QLabel, QVBoxLayout, QWidget
|
||||
|
||||
from bec_widgets import BECWidget
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.utility.spinner.spinner import SpinnerWidget
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
class _TestBusyWidget(BECWidget, QWidget):
|
||||
def __init__(self, parent=None, *, start_busy: bool = False, **kwargs):
|
||||
|
||||
@@ -4,11 +4,11 @@ from pydantic import ValidationError
|
||||
from qtpy.QtGui import QColor
|
||||
from qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.bec_connector import ConnectionConfig
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.utils.colors import Colors, apply_theme, get_theme_name, rgba, theme_color
|
||||
from bec_widgets.widgets.plots.waveform.curve import CurveConfig
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
from tests.unit_tests.conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import pytest
|
||||
from qtpy.QtCore import QPointF, Qt
|
||||
from qtpy.QtGui import QTransform
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.crosshair import Crosshair
|
||||
from bec_widgets.widgets.plots.image.image_item import ImageItem
|
||||
from bec_widgets.widgets.plots.waveform.waveform import Waveform
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import pytest
|
||||
from bec_lib.scan_history import ScanHistory
|
||||
from qtpy.QtWidgets import QComboBox, QVBoxLayout
|
||||
|
||||
from bec_widgets.tests.client_mocks import dap_plugin_message, mocked_client, mocked_client_with_dap
|
||||
from bec_widgets.widgets.plots.waveform.settings.curve_settings.curve_setting import CurveSetting
|
||||
from bec_widgets.widgets.plots.waveform.settings.curve_settings.curve_tree import CurveTree
|
||||
from bec_widgets.widgets.plots.waveform.waveform import Waveform
|
||||
from tests.unit_tests.client_mocks import dap_plugin_message, mocked_client, mocked_client_with_dap
|
||||
from tests.unit_tests.conftest import create_widget
|
||||
|
||||
##################################################
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.dap.dap_combo_box.dap_combo_box import DapComboBox
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@ from unittest import mock
|
||||
import pytest
|
||||
from qtpy.QtCore import Qt
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.colors import apply_theme
|
||||
from bec_widgets.widgets.utility.visual.dark_mode_button.dark_mode_button import DarkModeButton
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
|
||||
|
||||
@@ -18,12 +18,11 @@ import pytest
|
||||
from qtpy.QtWidgets import QDialog
|
||||
|
||||
from bec_widgets.applications.views.developer_view.developer_widget import DeveloperWidget
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.editors.monaco.monaco_dock import MonacoDock
|
||||
from bec_widgets.widgets.editors.monaco.monaco_widget import MonacoWidget
|
||||
from bec_widgets.widgets.utility.ide_explorer.ide_explorer import IDEExplorer
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def developer_view(qtbot, mocked_client):
|
||||
|
||||
@@ -6,6 +6,7 @@ from bec_lib.device import Device
|
||||
from qtpy.QtCore import QPoint, Qt
|
||||
from qtpy.QtWidgets import QTabWidget
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.services.device_browser.device_browser import DeviceBrowser
|
||||
from bec_widgets.widgets.services.device_browser.device_item.device_config_form import (
|
||||
DeviceConfigForm,
|
||||
@@ -14,8 +15,6 @@ from bec_widgets.widgets.services.device_browser.device_item.device_signal_displ
|
||||
SignalDisplay,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from qtpy.QtWidgets import QListWidgetItem
|
||||
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
import pytest
|
||||
from bec_lib.messages import DeviceInitializationProgressMessage
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.progress.device_initialization_progress_bar.device_initialization_progress_bar import (
|
||||
DeviceInitializationProgressBar,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def progress_bar(qtbot, mocked_client):
|
||||
|
||||
@@ -2,13 +2,13 @@ from unittest import mock
|
||||
|
||||
from bec_lib.device import Positioner, ReadoutPriority
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.control.device_input.device_combobox.device_combobox import (
|
||||
BECDeviceFilter,
|
||||
DeviceComboBox,
|
||||
DeviceInputConfig,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -3,14 +3,13 @@ from unittest import mock
|
||||
import pytest
|
||||
from bec_lib.device import ReadoutPriority
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.tests.fake_devices import FakeDevice
|
||||
from bec_widgets.widgets.control.device_input.device_combobox.device_combobox import (
|
||||
BECDeviceFilter,
|
||||
DeviceComboBox,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def device_input_combobox(qtbot, mocked_client):
|
||||
|
||||
@@ -14,6 +14,7 @@ from ophyd_devices.interfaces.device_config_templates.ophyd_templates import (
|
||||
from ophyd_devices.utils.static_device_test import TestResult
|
||||
from qtpy import QtCore, QtGui, QtWidgets
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.bec_list import BECList
|
||||
from bec_widgets.utils.colors import get_accent_colors
|
||||
from bec_widgets.widgets.control.device_manager import DeviceTable, DMConfigView, DocstringView
|
||||
@@ -57,8 +58,6 @@ from bec_widgets.widgets.control.device_manager.components.ophyd_validation.vali
|
||||
)
|
||||
from bec_widgets.widgets.utility.toggle.toggle import ToggleSwitch
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
class TestConstants:
|
||||
"""Test class for constants and configuration values."""
|
||||
|
||||
@@ -30,6 +30,7 @@ from bec_widgets.applications.views.device_manager_view.device_manager_view impo
|
||||
DeviceManagerView,
|
||||
DeviceManagerWidget,
|
||||
)
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.colors import get_accent_colors
|
||||
from bec_widgets.widgets.control.device_manager.components import (
|
||||
DeviceTable,
|
||||
@@ -43,8 +44,6 @@ from bec_widgets.widgets.control.device_manager.components.ophyd_validation.ophy
|
||||
OphydValidation,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def device_config() -> dict:
|
||||
|
||||
@@ -7,6 +7,7 @@ from bec_lib.callback_handler import EventType
|
||||
from bec_lib.device import Signal
|
||||
from qtpy.QtCore import Qt
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.ophyd_kind_util import Kind
|
||||
from bec_widgets.widgets.control.device_input.device_combobox.device_combobox import (
|
||||
BECDeviceFilter,
|
||||
@@ -17,7 +18,6 @@ from bec_widgets.widgets.control.device_input.signal_combobox.signal_combobox im
|
||||
SignalComboBoxConfig,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ from qtpy.QtWidgets import QDialog, QMessageBox, QToolButton, QWidget
|
||||
import bec_widgets.widgets.containers.dock_area.basic_dock_area as basic_dock_module
|
||||
import bec_widgets.widgets.containers.dock_area.dock_area as dock_area_module
|
||||
import bec_widgets.widgets.containers.dock_area.profile_utils as profile_utils
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.containers.dock_area.basic_dock_area import (
|
||||
DockAreaWidget,
|
||||
DockSettingsDialog,
|
||||
@@ -44,8 +45,6 @@ from bec_widgets.widgets.containers.dock_area.settings.dialogs import (
|
||||
from bec_widgets.widgets.containers.dock_area.settings.workspace_manager import WorkSpaceManager
|
||||
from bec_widgets.widgets.plots.waveform.waveform import Waveform
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def advanced_dock_area(qtbot, mocked_client):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from qtpy.QtWidgets import QComboBox
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.filter_io import get_bec_signals_for_classes, replace_combobox_items
|
||||
from bec_widgets.widgets.dap.dap_combo_box.dap_combo_box import DapComboBox
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from bec_lib.scan_args import ScanArgument
|
||||
from pydantic import BaseModel, Field
|
||||
from qtpy.QtWidgets import QCheckBox, QLabel, QLineEdit
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.forms_from_types.forms import PydanticModelForm, TypedForm
|
||||
from bec_widgets.utils.forms_from_types.items import FloatDecimalFormItem, IntFormItem, StrFormItem
|
||||
from bec_widgets.utils.forms_from_types.pydantic_widget_form import (
|
||||
@@ -18,8 +19,6 @@ from bec_widgets.widgets.control.device_input.device_combobox.device_combobox im
|
||||
from bec_widgets.widgets.control.device_input.signal_combobox.signal_combobox import SignalComboBox
|
||||
from bec_widgets.widgets.utility.spinbox.decimal_spinbox import BECSpinBox
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
# pylint: disable=no-member
|
||||
# pylint: disable=missing-function-docstring
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
@@ -7,6 +7,8 @@ from bec_lib.scan_history import ScanHistory
|
||||
from qtpy.QtCore import QPointF
|
||||
from qtpy.QtGui import QTransform
|
||||
|
||||
# pytest: disable=unused-import
|
||||
from bec_widgets.tests.client_mocks import create_dummy_scan_item, mocked_client
|
||||
from bec_widgets.widgets.plots.heatmap.heatmap import (
|
||||
Heatmap,
|
||||
HeatmapConfig,
|
||||
@@ -16,11 +18,6 @@ from bec_widgets.widgets.plots.heatmap.heatmap import (
|
||||
)
|
||||
from bec_widgets.widgets.plots.plot_info_label import TextOnlyLegendSample
|
||||
|
||||
# pytest: disable=unused-import
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
|
||||
from .client_mocks import create_dummy_scan_item
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def heatmap_widget(qtbot, mocked_client):
|
||||
|
||||
@@ -5,12 +5,11 @@ from unittest import mock
|
||||
import pytest
|
||||
from qtpy import QtCore, QtWidgets
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.help_inspector.help_inspector import HelpInspector
|
||||
from bec_widgets.utils.widget_io import WidgetHierarchy
|
||||
from bec_widgets.widgets.control.buttons.button_abort.button_abort import AbortButton
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def help_inspector(qtbot, mocked_client):
|
||||
|
||||
@@ -4,10 +4,10 @@ import numpy as np
|
||||
import pytest
|
||||
from qtpy.QtCore import QPointF, Qt
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.image.image import Image
|
||||
from bec_widgets.widgets.plots.image.setting_widgets.image_roi_tree import ROIPropertyTree
|
||||
from bec_widgets.widgets.plots.roi.image_roi import CircularROI, RectangularROI
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
from tests.unit_tests.conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from typing import Literal
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.image.image import Image
|
||||
from bec_widgets.widgets.plots.roi.image_roi import (
|
||||
CircularROI,
|
||||
@@ -12,7 +13,6 @@ from bec_widgets.widgets.plots.roi.image_roi import (
|
||||
RectangularROI,
|
||||
ROIController,
|
||||
)
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
from tests.unit_tests.conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ import pytest
|
||||
from bec_lib.endpoints import MessageEndpoints
|
||||
from qtpy.QtCore import QPointF, Qt
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.image.bec_histogram_lut_item import (
|
||||
BECColorBarItem,
|
||||
BECHistogramLUTItem,
|
||||
)
|
||||
from bec_widgets.widgets.plots.image.image import Image
|
||||
from bec_widgets.widgets.plots.image.image_processor import ImageProcessor, ProcessingConfig
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
from tests.unit_tests.conftest import create_widget
|
||||
|
||||
##################################################
|
||||
|
||||
@@ -10,11 +10,10 @@ from qtpy.QtWidgets import QWidget
|
||||
|
||||
import bec_widgets
|
||||
from bec_widgets.applications.launch_window import START_EMPTY_PROFILE_OPTION, LaunchWindow
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.containers.auto_update.auto_updates import AutoUpdates
|
||||
from bec_widgets.widgets.containers.main_window.main_window import BECMainWindow
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
base_path = os.path.dirname(bec_widgets.__file__)
|
||||
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ from unittest import mock
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.dap.lmfit_dialog.lmfit_dialog import LMFitDialog
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -12,11 +12,10 @@ from bec_lib.logger import LogLevel
|
||||
from bec_lib.messages import LogMessage
|
||||
from qtpy.QtCore import QDateTime, Qt
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.colors import apply_theme, get_accent_colors, get_theme_name
|
||||
from bec_widgets.widgets.utility.logpanel.logpanel import LogPanel, TimestampUpdate
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
TEST_LOG_MESSAGES = [
|
||||
{"data": msg}
|
||||
for msg in [
|
||||
|
||||
@@ -4,14 +4,13 @@ from qtpy.QtWidgets import QWidget
|
||||
|
||||
from bec_widgets.applications.main_app import BECMainApp
|
||||
from bec_widgets.applications.views.view import ViewBase
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.widgets.containers.dock_area.profile_utils import (
|
||||
is_experimental_features_enabled,
|
||||
set_experimental_features_enabled,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
ANIM_TEST_DURATION = 60 # ms
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from qtpy.QtCore import QEvent, QPoint, QPointF, QSettings
|
||||
from qtpy.QtGui import QEnterEvent
|
||||
from qtpy.QtWidgets import QApplication, QFrame, QLabel, QMessageBox
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.containers.dock_area.profile_utils import SETTINGS_KEYS
|
||||
from bec_widgets.widgets.containers.main_window.addons.hover_widget import (
|
||||
HoverWidget,
|
||||
@@ -17,7 +18,6 @@ from bec_widgets.widgets.containers.main_window.addons.scroll_label import Scrol
|
||||
from bec_widgets.widgets.containers.main_window.addons.web_links import BECWebLinksMixin
|
||||
from bec_widgets.widgets.containers.main_window.main_window import BECMainWindow
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -5,11 +5,10 @@ from unittest import mock
|
||||
import pytest
|
||||
from qtpy.QtWidgets import QFileDialog, QMessageBox
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.editors.monaco.monaco_dock import MonacoDock
|
||||
from bec_widgets.widgets.editors.monaco.monaco_widget import MonacoWidget
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def monaco_dock(qtbot, mocked_client) -> Generator[MonacoDock, None, None]:
|
||||
|
||||
@@ -3,11 +3,11 @@ from unittest import mock
|
||||
import pytest
|
||||
from bec_lib.endpoints import MessageEndpoints
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.widget_io import WidgetIO
|
||||
from bec_widgets.widgets.editors.monaco.monaco_widget import MonacoWidget
|
||||
from bec_widgets.widgets.editors.monaco.scan_control_dialog import ScanControlDialog
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .test_scan_control import available_scans_message
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from qtpy.QtTest import QSignalSpy
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.motor_map.motor_map import MotorMap
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import numpy as np
|
||||
from bec_lib import messages
|
||||
from bec_lib.scan_items import ScanItem
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.multi_waveform.multi_waveform import MultiWaveform
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
from qtpy import QtCore, QtGui, QtWidgets
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.error_popups import ErrorPopupUtility
|
||||
from bec_widgets.widgets.containers.main_window.addons.notification_center.notification_banner import (
|
||||
DARK_PALETTE,
|
||||
@@ -13,8 +14,6 @@ from bec_widgets.widgets.containers.main_window.addons.notification_center.notif
|
||||
SeverityKind,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def toast(qtbot):
|
||||
|
||||
@@ -2,10 +2,9 @@ import pytest
|
||||
from qtpy.QtPdf import QPdfDocument
|
||||
from qtpy.QtPdfWidgets import QPdfView
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.utility.pdf_viewer.pdf_viewer import PdfViewerWidget
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pdf_viewer_widget(qtbot, mocked_client):
|
||||
|
||||
@@ -4,6 +4,7 @@ from bec_lib import messages
|
||||
from bec_lib.scan_data_container import ScanDataContainer
|
||||
from bec_lib.scan_items import ScanItem
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.heatmap.heatmap import Heatmap
|
||||
from bec_widgets.widgets.plots.image.image import Image
|
||||
from bec_widgets.widgets.plots.motor_map.motor_map import MotorMap
|
||||
@@ -13,7 +14,6 @@ from bec_widgets.widgets.plots.plot_info_label import TextOnlyLegendSample
|
||||
from bec_widgets.widgets.plots.scatter_waveform.scatter_waveform import ScatterWaveform
|
||||
from bec_widgets.widgets.plots.waveform.waveform import Waveform
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
# pylint: disable=unused-import
|
||||
|
||||
@@ -7,6 +7,7 @@ from qtpy.QtCore import Qt, QTimer
|
||||
from qtpy.QtGui import QValidator
|
||||
from qtpy.QtWidgets import QPushButton
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.tests.fake_devices import Positioner
|
||||
from bec_widgets.widgets.control.device_control.positioner_box import (
|
||||
PositionerBox,
|
||||
@@ -14,7 +15,6 @@ from bec_widgets.widgets.control.device_control.positioner_box import (
|
||||
)
|
||||
from bec_widgets.widgets.control.device_input.device_combobox.device_combobox import DeviceComboBox
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import pytest
|
||||
from bec_lib.endpoints import MessageEndpoints
|
||||
from bec_lib.messages import VariableMessage
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.control.device_control.positioner_box import PositionerBox2D
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -5,10 +5,9 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
from qtpy.QtWidgets import QMessageBox
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.control.buttons.button_reset.button_reset import ResetButton
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def reset_button(qtbot, mocked_client):
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.control.buttons.button_resume.button_resume import ResumeButton
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def resume_button(qtbot, mocked_client):
|
||||
|
||||
@@ -8,14 +8,13 @@ from qtpy.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from qtpy.QtGui import QColor, QMouseEvent
|
||||
from qtpy.QtWidgets import QApplication
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.colors import Colors
|
||||
from bec_widgets.widgets.progress.ring_progress_bar.ring_progress_bar import (
|
||||
RingProgressBar,
|
||||
RingProgressContainerWidget,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ring_progress_bar(qtbot, mocked_client):
|
||||
|
||||
@@ -6,14 +6,13 @@ import pytest
|
||||
from bec_lib.endpoints import MessageEndpoints
|
||||
from qtpy.QtGui import QColor
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.tests.fake_devices import FakeDevice
|
||||
from bec_widgets.widgets.progress.ring_progress_bar.ring import ProgressbarConfig, Ring
|
||||
from bec_widgets.widgets.progress.ring_progress_bar.ring_progress_bar import (
|
||||
RingProgressContainerWidget,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ring_container(qtbot, mocked_client):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.settings_dialog import SettingsDialog
|
||||
from bec_widgets.widgets.progress.ring_progress_bar.ring_progress_bar import RingProgressBar
|
||||
from bec_widgets.widgets.progress.ring_progress_bar.ring_progress_settings_cards import RingSettings
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -7,12 +7,11 @@ from qtpy.QtWidgets import QWidget
|
||||
|
||||
from bec_widgets.applications import companion_app as companion_app_module
|
||||
from bec_widgets.applications.companion_app import GUIServer
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils import rpc_server as rpc_server_module
|
||||
from bec_widgets.utils.bec_connector import BECConnector
|
||||
from bec_widgets.utils.rpc_server import RegistryNotReadyError, RPCServer, SingleshotRPCRepeat
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
class DummyWidget(BECConnector, QWidget):
|
||||
def __init__(self, parent=None, client=None, **kwargs):
|
||||
|
||||
@@ -10,6 +10,7 @@ from bec_lib.scan_history import ScanHistory
|
||||
from qtpy.QtCore import QModelIndex, QPoint, Qt
|
||||
from qtpy.QtWidgets import QCheckBox, QComboBox, QDialog, QStyle
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.forms_from_types.items import StrFormItem
|
||||
from bec_widgets.utils.widget_io import WidgetIO
|
||||
from bec_widgets.widgets.control.device_input.device_combobox.device_combobox import DeviceComboBox
|
||||
@@ -19,8 +20,6 @@ from bec_widgets.widgets.control.scan_control.scan_control import ScanControlCon
|
||||
from bec_widgets.widgets.control.scan_control.scan_info_adapter import ScanInfoAdapter
|
||||
from bec_widgets.widgets.control.scan_control.scan_selection_dialog import ScanSelectionDialog
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
# pylint: disable=no-member
|
||||
# pylint: disable=missing-function-docstring
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
@@ -5,6 +5,7 @@ from bec_lib.messages import ScanHistoryMessage, _StoredDataInfo
|
||||
from pytestqt import qtbot
|
||||
from qtpy import QtCore
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.colors import get_accent_colors
|
||||
from bec_widgets.widgets.services.scan_history_browser.components import (
|
||||
ScanHistoryDeviceViewer,
|
||||
@@ -15,8 +16,6 @@ from bec_widgets.widgets.services.scan_history_browser.scan_history_browser impo
|
||||
ScanHistoryBrowser,
|
||||
)
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def scan_history_msg():
|
||||
|
||||
@@ -2,10 +2,9 @@ import pytest
|
||||
from bec_lib.scan_history import ScanHistory
|
||||
from qtpy.QtCore import Qt
|
||||
|
||||
from bec_widgets.widgets.utility.scan_index_combobox.scan_index_combobox import ScanIndexComboBox
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.utility.scan_index_combobox.scan_index_combobox import ScanIndexComboBox
|
||||
from tests.unit_tests.conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import numpy as np
|
||||
import pytest
|
||||
from bec_lib.endpoints import MessageEndpoints
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.widgets.progress.bec_progressbar.bec_progressbar import (
|
||||
BECProgressBar,
|
||||
@@ -12,8 +13,6 @@ from bec_widgets.widgets.progress.bec_progressbar.bec_progressbar import (
|
||||
from bec_widgets.widgets.progress.progress_backend import ProgressTask
|
||||
from bec_widgets.widgets.progress.scan_progressbar.scan_progressbar import ScanProgressBar
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def scan_progressbar(qtbot, mocked_client):
|
||||
|
||||
@@ -3,6 +3,12 @@ from unittest.mock import patch
|
||||
import numpy as np
|
||||
from bec_lib.scan_data_container import ScanDataContainer
|
||||
|
||||
from bec_widgets.tests.client_mocks import (
|
||||
DummyData,
|
||||
create_dummy_scan_item,
|
||||
inject_scan_history,
|
||||
mocked_client,
|
||||
)
|
||||
from bec_widgets.widgets.plots.scatter_waveform.scatter_curve import (
|
||||
ScatterCurveConfig,
|
||||
ScatterDeviceSignal,
|
||||
@@ -11,12 +17,6 @@ from bec_widgets.widgets.plots.scatter_waveform.scatter_waveform import ScatterW
|
||||
from bec_widgets.widgets.plots.scatter_waveform.settings.scatter_curve_setting import (
|
||||
ScatterCurveSettings,
|
||||
)
|
||||
from tests.unit_tests.client_mocks import (
|
||||
DummyData,
|
||||
create_dummy_scan_item,
|
||||
inject_scan_history,
|
||||
mocked_client,
|
||||
)
|
||||
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ import pytest
|
||||
from qtpy import QtCore
|
||||
from qtpy.QtWidgets import QDialogButtonBox, QLabel
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.control.device_input.signal_combobox.signal_combobox import (
|
||||
SignalComboBoxConfig,
|
||||
)
|
||||
from bec_widgets.widgets.utility.signal_label.signal_label import ChoiceDialog, SignalLabel
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
SAMX_INFO_DICT = {
|
||||
"signals": {
|
||||
"readback": {
|
||||
|
||||
@@ -4,10 +4,9 @@ from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.control.buttons.stop_button.stop_button import StopButton
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def stop_button(qtbot, mocked_client):
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.editors.text_box.text_box import DEFAULT_TEXT, TextBox
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def text_box_widget(qtbot, mocked_client):
|
||||
|
||||
@@ -3,10 +3,10 @@ from unittest import mock
|
||||
import pyqtgraph as pg
|
||||
import pytest
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.bec_signal_proxy import BECSignalProxy
|
||||
from bec_widgets.widgets.dap.dap_combo_box.dap_combo_box import DapComboBox
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import pytest
|
||||
from qtpy.QtCore import QPointF
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.plots.waveform.waveform import Waveform
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def plot_widget_with_arrow_item(qtbot, mocked_client):
|
||||
|
||||
@@ -15,13 +15,7 @@ from pyqtgraph.graphicsItems.DateAxisItem import DateAxisItem
|
||||
from qtpy.QtCore import QTimer
|
||||
from qtpy.QtWidgets import QApplication, QCheckBox, QDialog, QDialogButtonBox, QDoubleSpinBox
|
||||
|
||||
from bec_widgets.widgets.plots.plot_base import UIMode
|
||||
from bec_widgets.widgets.plots.waveform.curve import DeviceSignal
|
||||
from bec_widgets.widgets.plots.waveform.waveform import Waveform
|
||||
from bec_widgets.widgets.services.scan_history_browser.scan_history_browser import (
|
||||
ScanHistoryBrowser,
|
||||
)
|
||||
from tests.unit_tests.client_mocks import (
|
||||
from bec_widgets.tests.client_mocks import (
|
||||
DummyData,
|
||||
create_dummy_scan_item,
|
||||
dap_plugin_message,
|
||||
@@ -29,6 +23,12 @@ from tests.unit_tests.client_mocks import (
|
||||
mocked_client,
|
||||
mocked_client_with_dap,
|
||||
)
|
||||
from bec_widgets.widgets.plots.plot_base import UIMode
|
||||
from bec_widgets.widgets.plots.waveform.curve import DeviceSignal
|
||||
from bec_widgets.widgets.plots.waveform.waveform import Waveform
|
||||
from bec_widgets.widgets.services.scan_history_browser.scan_history_browser import (
|
||||
ScanHistoryBrowser,
|
||||
)
|
||||
|
||||
from .conftest import create_widget
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import pytest
|
||||
from qtpy.QtCore import QUrl
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.widgets.editors.website.website import WebsiteWidget
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def website_widget(qtbot, mocked_client):
|
||||
|
||||
@@ -15,13 +15,12 @@ from qtpy.QtWidgets import (
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from bec_widgets.tests.client_mocks import mocked_client
|
||||
from bec_widgets.utils.widget_io import WidgetHierarchy, WidgetIO, WidgetTreeNode
|
||||
from bec_widgets.widgets.control.device_input.device_combobox.device_combobox import DeviceComboBox
|
||||
from bec_widgets.widgets.control.device_input.signal_combobox.signal_combobox import SignalComboBox
|
||||
from bec_widgets.widgets.utility.toggle.toggle import ToggleSwitch
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def example_widget(qtbot):
|
||||
|
||||
Reference in New Issue
Block a user