bec-widgets 0.46.5__py3-none-any.whl → 0.46.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bec_widgets/cli/client_utils.py +11 -0
- {bec_widgets-0.46.5.dist-info → bec_widgets-0.46.6.dist-info}/METADATA +1 -1
- {bec_widgets-0.46.5.dist-info → bec_widgets-0.46.6.dist-info}/RECORD +7 -6
- tests/unit_tests/test_client_utils.py +29 -0
- {bec_widgets-0.46.5.dist-info → bec_widgets-0.46.6.dist-info}/LICENSE +0 -0
- {bec_widgets-0.46.5.dist-info → bec_widgets-0.46.6.dist-info}/WHEEL +0 -0
- {bec_widgets-0.46.5.dist-info → bec_widgets-0.46.6.dist-info}/top_level.txt +0 -0
bec_widgets/cli/client_utils.py
CHANGED
@@ -36,6 +36,17 @@ def rpc_call(func):
|
|
36
36
|
|
37
37
|
@wraps(func)
|
38
38
|
def wrapper(self, *args, **kwargs):
|
39
|
+
# we could rely on a strict type check here, but this is more flexible
|
40
|
+
# moreover, it would anyway crash for objects...
|
41
|
+
out = []
|
42
|
+
for arg in args:
|
43
|
+
if hasattr(arg, "name"):
|
44
|
+
arg = arg.name
|
45
|
+
out.append(arg)
|
46
|
+
args = tuple(out)
|
47
|
+
for key, val in kwargs.items():
|
48
|
+
if hasattr(val, "name"):
|
49
|
+
kwargs[key] = val.name
|
39
50
|
if not self.gui_is_alive():
|
40
51
|
raise RuntimeError("GUI is not alive")
|
41
52
|
return self._run_rpc(func.__name__, *args, **kwargs)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
bec_widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
bec_widgets/cli/__init__.py,sha256=yFyAmDteCcndbReunhnrfDib6JujQ7-BKWeVvuU0Ylw,30
|
3
3
|
bec_widgets/cli/client.py,sha256=4QedDVBgkCOnRQFYQcAabyAsl5UQ0aRwwLwk1OR5M1k,37882
|
4
|
-
bec_widgets/cli/client_utils.py,sha256=
|
4
|
+
bec_widgets/cli/client_utils.py,sha256=zsFHcE75IWoPKh5NCawUVbE20_o_7ggPWkj7_49-Bns,10939
|
5
5
|
bec_widgets/cli/generate_cli.py,sha256=JLqUlUgfz_f_4KHPRUAN-Xli-K7uNOc8-F-LkAC7Scw,4004
|
6
6
|
bec_widgets/cli/server.py,sha256=OMWnl99RrSTKK1EVEyu3MFjkJ54bWfh_fpg38b-bres,4760
|
7
7
|
bec_widgets/examples/__init__.py,sha256=WWQ0cu7m8sA4Ehy-DWdTIqSISjaHsbxhsNmNrMnhDZU,202
|
@@ -75,6 +75,7 @@ tests/unit_tests/test_bec_dispatcher.py,sha256=MtNyfC7-Y4na-Fwf1ny9raHBqE45eSnQN
|
|
75
75
|
tests/unit_tests/test_bec_figure.py,sha256=T4k-E1D3sjTTDTFZGdTFDQv0EYNQ_R-QbWOM7pQwFw4,7926
|
76
76
|
tests/unit_tests/test_bec_monitor.py,sha256=mN7gBY7oXY6j65zzihpy8r-FvwVoCQlie3F6SoVq0mo,7042
|
77
77
|
tests/unit_tests/test_bec_motor_map.py,sha256=IXSfitUGxOPqmngwVNPK5nwi2QDcXWjBkGNb0dBZDxQ,4611
|
78
|
+
tests/unit_tests/test_client_utils.py,sha256=fIApd5WgnJuyIzV-hdSABn6T-aOel2Wr2xuUX4Z651A,774
|
78
79
|
tests/unit_tests/test_config_dialog.py,sha256=5uNGcpvrx8qDdMwFCTXr8HMzFZF4rFi-ZHoDpMxGMf8,6955
|
79
80
|
tests/unit_tests/test_crosshair.py,sha256=d7fX-ymboZPALNqqiAj86PZ96llmGZ_3jf0yjVP0S94,5039
|
80
81
|
tests/unit_tests/test_editor.py,sha256=TED5k1xFJHRZ4KDAg2VxSRu_hMJnra-lbAmVwsDicsM,6784
|
@@ -91,8 +92,8 @@ tests/unit_tests/test_widget_io.py,sha256=FeL3ZYSBQnRt6jxj8VGYw1cmcicRQyHKleahw7
|
|
91
92
|
tests/unit_tests/test_yaml_dialog.py,sha256=HNrqferkdg02-9ieOhhI2mr2Qvt7GrYgXmQ061YCTbg,5794
|
92
93
|
tests/unit_tests/test_msgs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
93
94
|
tests/unit_tests/test_msgs/available_scans_message.py,sha256=m_z97hIrjHXXMa2Ex-UvsPmTxOYXfjxyJaGkIY6StTY,46532
|
94
|
-
bec_widgets-0.46.
|
95
|
-
bec_widgets-0.46.
|
96
|
-
bec_widgets-0.46.
|
97
|
-
bec_widgets-0.46.
|
98
|
-
bec_widgets-0.46.
|
95
|
+
bec_widgets-0.46.6.dist-info/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
|
96
|
+
bec_widgets-0.46.6.dist-info/METADATA,sha256=b8I7vt8YPo-TpWiWV8Jh1-YABgTVjf-JD-UKyYWyZW8,3714
|
97
|
+
bec_widgets-0.46.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
98
|
+
bec_widgets-0.46.6.dist-info/top_level.txt,sha256=EXCwhJYmXmd1DjYYL3hrGsddX-97IwYSiIHrf27FFVk,18
|
99
|
+
bec_widgets-0.46.6.dist-info/RECORD,,
|
@@ -0,0 +1,29 @@
|
|
1
|
+
from unittest import mock
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
from bec_widgets.cli.client import BECFigure
|
6
|
+
|
7
|
+
from .client_mocks import FakeDevice
|
8
|
+
|
9
|
+
|
10
|
+
@pytest.fixture
|
11
|
+
def cli_figure():
|
12
|
+
fig = BECFigure(gui_id="test")
|
13
|
+
with mock.patch.object(fig, "_run_rpc") as mock_rpc_call:
|
14
|
+
with mock.patch.object(fig, "gui_is_alive", return_value=True):
|
15
|
+
yield fig, mock_rpc_call
|
16
|
+
|
17
|
+
|
18
|
+
def test_rpc_call_plot(cli_figure):
|
19
|
+
fig, mock_rpc_call = cli_figure
|
20
|
+
fig.plot("samx", "bpm4i")
|
21
|
+
mock_rpc_call.assert_called_with("plot", "samx", "bpm4i")
|
22
|
+
|
23
|
+
|
24
|
+
def test_rpc_call_accepts_device_as_input(cli_figure):
|
25
|
+
dev1 = FakeDevice("samx")
|
26
|
+
dev2 = FakeDevice("bpm4i")
|
27
|
+
fig, mock_rpc_call = cli_figure
|
28
|
+
fig.plot(dev1, dev2)
|
29
|
+
mock_rpc_call.assert_called_with("plot", "samx", "bpm4i")
|
File without changes
|
File without changes
|
File without changes
|