bec-widgets 0.59.1__py3-none-any.whl → 0.61.0__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.
@@ -1,10 +1,12 @@
1
1
  from textwrap import dedent
2
2
 
3
3
  import black
4
- import pytest
4
+ import isort
5
5
 
6
6
  from bec_widgets.cli.generate_cli import ClientGenerator
7
7
 
8
+ # pylint: disable=missing-function-docstring
9
+
8
10
 
9
11
  # Mock classes to test the generator
10
12
  class MockBECWaveform1D:
@@ -24,25 +26,39 @@ class MockBECFigure:
24
26
 
25
27
  def add_plot(self, plot_id: str):
26
28
  """Add a plot to the figure."""
27
- pass
28
29
 
29
30
  def remove_plot(self, plot_id: str):
30
31
  """Remove a plot from the figure."""
31
- pass
32
32
 
33
33
 
34
34
  def test_client_generator_with_black_formatting():
35
35
  generator = ClientGenerator()
36
- generator.generate_client([MockBECWaveform1D, MockBECFigure])
36
+ rpc_classes = {
37
+ "connector_classes": [MockBECWaveform1D, MockBECFigure],
38
+ "top_level_classes": [MockBECFigure],
39
+ }
40
+ generator.generate_client(rpc_classes)
37
41
 
38
42
  # Format the expected output with black to ensure it matches the generator output
39
43
  expected_output = dedent(
40
44
  '''\
41
45
  # This file was automatically generated by generate_cli.py
42
46
 
43
- from bec_widgets.cli.client_utils import rpc_call, RPCBase, BECGuiClientMixin
47
+ import enum
44
48
  from typing import Literal, Optional, overload
45
49
 
50
+ from bec_widgets.cli.client_utils import BECGuiClientMixin, RPCBase, rpc_call
51
+
52
+ # pylint: skip-file
53
+
54
+ class Widgets(str, enum.Enum):
55
+ """
56
+ Enum for the available widgets.
57
+ """
58
+
59
+ MockBECFigure = "MockBECFigure"
60
+
61
+
46
62
  class MockBECWaveform1D(RPCBase):
47
63
  @rpc_call
48
64
  def set_frequency(self, frequency: float) -> list:
@@ -78,4 +94,20 @@ def test_client_generator_with_black_formatting():
78
94
  generator.header + "\n" + generator.content, mode=black.FileMode(line_length=100)
79
95
  )
80
96
 
97
+ generated_output_formatted = isort.code(generated_output_formatted)
98
+
81
99
  assert expected_output_formatted == generated_output_formatted
100
+
101
+
102
+ def test_client_generator_classes():
103
+ generator = ClientGenerator()
104
+ out = generator.get_rpc_classes("bec_widgets")
105
+ assert list(out.keys()) == ["connector_classes", "top_level_classes"]
106
+ connector_cls_names = [cls.__name__ for cls in out["connector_classes"]]
107
+ top_level_cls_names = [cls.__name__ for cls in out["top_level_classes"]]
108
+
109
+ assert "BECFigure" in connector_cls_names
110
+ assert "BECWaveform" in connector_cls_names
111
+ assert "BECDockArea" in top_level_cls_names
112
+ assert "BECFigure" in top_level_cls_names
113
+ assert "BECWaveform" not in top_level_cls_names
@@ -0,0 +1,25 @@
1
+ # pylint: disable=missing-function-docstring, missing-module-docstring, unused-import
2
+
3
+ import pytest
4
+
5
+ from bec_widgets.widgets import StopButton
6
+
7
+ from .client_mocks import mocked_client
8
+
9
+
10
+ @pytest.fixture
11
+ def stop_button(qtbot, mocked_client):
12
+ widget = StopButton(client=mocked_client)
13
+ qtbot.addWidget(widget)
14
+ qtbot.waitExposed(widget)
15
+ yield widget
16
+ widget.close()
17
+
18
+
19
+ def test_stop_button(stop_button):
20
+ assert stop_button.text() == "Stop"
21
+ assert stop_button.styleSheet() == "background-color: #cc181e; color: white"
22
+ stop_button.click()
23
+ assert stop_button.queue.request_scan_abortion.called
24
+ assert stop_button.queue.request_queue_reset.called
25
+ stop_button.close()