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

fix(cli): fixed support for devices as cli input

This commit is contained in:
2024-04-19 11:52:04 +02:00
committed by wyzula-jan
parent 81484e8160
commit 1111610f32
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,29 @@
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("samx", "bpm4i")
mock_rpc_call.assert_called_with("plot", "samx", "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(dev1, dev2)
mock_rpc_call.assert_called_with("plot", "samx", "bpm4i")