mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
test(unit_tests): unit tests adjusted to use a modern plotting framework instead of BECFigure
This commit is contained in:
@ -3,31 +3,22 @@ from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from bec_widgets.cli.client import BECFigure
|
||||
from bec_widgets.cli.client import BECDockArea
|
||||
from bec_widgets.cli.client_utils import BECGuiClient, _start_plot_process
|
||||
from bec_widgets.tests.utils import FakeDevice
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cli_figure():
|
||||
fig = BECFigure(gui_id="test")
|
||||
with mock.patch.object(fig, "_run_rpc") as mock_rpc_call:
|
||||
with mock.patch.object(fig, "_gui_is_alive", return_value=True):
|
||||
yield fig, mock_rpc_call
|
||||
def cli_dock_area():
|
||||
dock_area = BECDockArea(gui_id="test")
|
||||
with mock.patch.object(dock_area, "_run_rpc") as mock_rpc_call:
|
||||
with mock.patch.object(dock_area, "_gui_is_alive", return_value=True):
|
||||
yield dock_area, mock_rpc_call
|
||||
|
||||
|
||||
def test_rpc_call_plot(cli_figure):
|
||||
fig, mock_rpc_call = cli_figure
|
||||
fig.plot(x_name="samx", y_name="bpm4i")
|
||||
mock_rpc_call.assert_called_with("plot", x_name="samx", y_name="bpm4i")
|
||||
|
||||
|
||||
def test_rpc_call_accepts_device_as_input(cli_figure):
|
||||
dev1 = FakeDevice("samx")
|
||||
dev2 = FakeDevice("bpm4i")
|
||||
fig, mock_rpc_call = cli_figure
|
||||
fig.plot(x_name=dev1, y_name=dev2)
|
||||
mock_rpc_call.assert_called_with("plot", x_name="samx", y_name="bpm4i")
|
||||
def test_rpc_call_new_dock(cli_dock_area):
|
||||
dock_area, mock_rpc_call = cli_dock_area
|
||||
dock_area.new(name="test")
|
||||
mock_rpc_call.assert_called_with("new", name="test")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@ -40,13 +31,13 @@ def test_rpc_call_accepts_device_as_input(cli_figure):
|
||||
)
|
||||
def test_client_utils_start_plot_process(config, call_config):
|
||||
with mock.patch("bec_widgets.cli.client_utils.subprocess.Popen") as mock_popen:
|
||||
_start_plot_process("gui_id", BECFigure, "bec", config)
|
||||
_start_plot_process("gui_id", BECDockArea, "bec", config)
|
||||
command = [
|
||||
"bec-gui-server",
|
||||
"--id",
|
||||
"gui_id",
|
||||
"--gui_class",
|
||||
"BECFigure",
|
||||
"BECDockArea",
|
||||
"--gui_class_id",
|
||||
"bec",
|
||||
"--hide",
|
||||
|
@ -7,7 +7,7 @@ from qtpy.QtWidgets import QVBoxLayout, QWidget
|
||||
from bec_widgets.utils import Colors, ConnectionConfig
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.utils.colors import apply_theme
|
||||
from bec_widgets.widgets.containers.figure.plots.waveform.waveform_curve import CurveConfig
|
||||
from bec_widgets.widgets.plots_next_gen.waveform.curve import CurveConfig
|
||||
from tests.unit_tests.client_mocks import mocked_client
|
||||
from tests.unit_tests.conftest import create_widget
|
||||
|
||||
|
@ -3,5 +3,5 @@ from bec_widgets.cli.rpc.rpc_widget_handler import RPCWidgetHandler
|
||||
|
||||
def test_rpc_widget_handler():
|
||||
handler = RPCWidgetHandler()
|
||||
assert "BECFigure" in handler.widget_classes
|
||||
assert "Image" in handler.widget_classes
|
||||
assert "RingProgressBar" in handler.widget_classes
|
||||
|
Reference in New Issue
Block a user