0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00
Files
bec_widgets/tests/unit_tests/test_client_utils.py

30 lines
830 B
Python

from unittest import mock
import pytest
from bec_widgets.cli.client import BECFigure
from .client_mocks 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 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")