bec-widgets 0.50.1__tar.gz → 0.51.0__tar.gz

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.
Files changed (113) hide show
  1. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/PKG-INFO +5 -5
  2. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/README.md +4 -4
  3. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/bec_dispatcher.py +9 -1
  4. bec_widgets-0.51.0/bec_widgets/utils/plugin_utils.py +40 -0
  5. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets.egg-info/PKG-INFO +5 -5
  6. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets.egg-info/SOURCES.txt +1 -0
  7. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets.egg-info/requires.txt +3 -3
  8. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/setup.py +4 -4
  9. bec_widgets-0.51.0/tests/unit_tests/test_bec_dispatcher.py +140 -0
  10. bec_widgets-0.50.1/tests/unit_tests/test_bec_dispatcher.py +0 -59
  11. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/LICENSE +0 -0
  12. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/__init__.py +0 -0
  13. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/cli/__init__.py +0 -0
  14. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/cli/auto_updates.py +0 -0
  15. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/cli/bec_widgets_icon.png +0 -0
  16. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/cli/client.py +0 -0
  17. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/cli/client_utils.py +0 -0
  18. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/cli/generate_cli.py +0 -0
  19. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/cli/rpc_register.py +0 -0
  20. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/cli/server.py +0 -0
  21. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/__init__.py +0 -0
  22. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/eiger_plot/__init__.py +0 -0
  23. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/eiger_plot/eiger_plot.py +0 -0
  24. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/eiger_plot/eiger_plot.ui +0 -0
  25. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/jupyter_console/__init__.py +0 -0
  26. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/jupyter_console/jupyter_console_window.py +0 -0
  27. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/jupyter_console/jupyter_console_window.ui +0 -0
  28. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/mca_readout/__init__.py +0 -0
  29. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/mca_readout/mca_plot.py +0 -0
  30. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/mca_readout/mca_sim.py +0 -0
  31. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/motor_movement/__init__.py +0 -0
  32. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/motor_movement/config_example.yaml +0 -0
  33. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/motor_movement/csax_bec_config.yaml +0 -0
  34. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/motor_movement/csaxs_config.yaml +0 -0
  35. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/motor_movement/motor_control_compilations.py +0 -0
  36. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/motor_movement/motor_controller.ui +0 -0
  37. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/motor_movement/motor_example.py +0 -0
  38. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/stream_plot/__init__.py +0 -0
  39. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/stream_plot/line_plot.ui +0 -0
  40. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/examples/stream_plot/stream_plot.py +0 -0
  41. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/simulations/__init__.py +0 -0
  42. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/__init__.py +0 -0
  43. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/bec_connector.py +0 -0
  44. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/bec_table.py +0 -0
  45. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/colors.py +0 -0
  46. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/container_utils.py +0 -0
  47. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/crosshair.py +0 -0
  48. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/ctrl_c.py +0 -0
  49. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/entry_validator.py +0 -0
  50. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/rpc_decorator.py +0 -0
  51. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/thread_checker.py +0 -0
  52. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/validator_delegate.py +0 -0
  53. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/widget_io.py +0 -0
  54. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/utils/yaml_dialog.py +0 -0
  55. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/validation/__init__.py +0 -0
  56. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/validation/monitor_config_validator.py +0 -0
  57. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/__init__.py +0 -0
  58. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/figure/__init__.py +0 -0
  59. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/figure/figure.py +0 -0
  60. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/monitor/__init__.py +0 -0
  61. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/monitor/config_dialog.py +0 -0
  62. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/monitor/config_dialog.ui +0 -0
  63. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/monitor/monitor.py +0 -0
  64. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/monitor/tab_template.ui +0 -0
  65. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/motor_control/__init__.py +0 -0
  66. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/motor_control/motor_control.py +0 -0
  67. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/motor_control/motor_control_absolute.ui +0 -0
  68. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/motor_control/motor_control_relative.ui +0 -0
  69. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/motor_control/motor_control_selection.ui +0 -0
  70. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/motor_control/motor_control_table.ui +0 -0
  71. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/motor_map/__init__.py +0 -0
  72. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/motor_map/motor_map.py +0 -0
  73. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/plots/__init__.py +0 -0
  74. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/plots/image.py +0 -0
  75. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/plots/motor_map.py +0 -0
  76. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/plots/plot_base.py +0 -0
  77. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/plots/waveform.py +0 -0
  78. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/scan_control/__init__.py +0 -0
  79. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/scan_control/scan_control.py +0 -0
  80. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/toolbar/__init__.py +0 -0
  81. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets/widgets/toolbar/toolbar.py +0 -0
  82. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets.egg-info/dependency_links.txt +0 -0
  83. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/bec_widgets.egg-info/top_level.txt +0 -0
  84. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/setup.cfg +0 -0
  85. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/__init__.py +0 -0
  86. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/end-2-end/__init__.py +0 -0
  87. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/end-2-end/conftest.py +0 -0
  88. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/end-2-end/test_bec_figure_rpc_e2e.py +0 -0
  89. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/end-2-end/test_rpc_register_e2e.py +0 -0
  90. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/__init__.py +0 -0
  91. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/client_mocks.py +0 -0
  92. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/conftest.py +0 -0
  93. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_bec_connector.py +0 -0
  94. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_bec_figure.py +0 -0
  95. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_bec_monitor.py +0 -0
  96. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_bec_motor_map.py +0 -0
  97. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_client_utils.py +0 -0
  98. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_config_dialog.py +0 -0
  99. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_crosshair.py +0 -0
  100. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_eiger_plot.py +0 -0
  101. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_generate_cli_client.py +0 -0
  102. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_motor_control.py +0 -0
  103. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_motor_map.py +0 -0
  104. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_msgs/__init__.py +0 -0
  105. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_msgs/available_scans_message.py +0 -0
  106. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_plot_base.py +0 -0
  107. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_rpc_register.py +0 -0
  108. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_scan_control.py +0 -0
  109. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_stream_plot.py +0 -0
  110. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_validator_errors.py +0 -0
  111. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_waveform1d.py +0 -0
  112. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_widget_io.py +0 -0
  113. {bec_widgets-0.50.1 → bec_widgets-0.51.0}/tests/unit_tests/test_yaml_dialog.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bec_widgets
3
- Version: 0.50.1
3
+ Version: 0.51.0
4
4
  Summary: BEC Widgets
5
5
  Home-page: https://gitlab.psi.ch/bec/bec-widgets
6
6
  Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec-widgets/issues
@@ -22,14 +22,14 @@ BEC Widgets is a GUI framework designed for interaction with [BEC (Beamline Expe
22
22
  Use the package manager [pip](https://pip.pypa.io/en/stable/) to install BEC Widgets:
23
23
 
24
24
  ```bash
25
- pip install bec-widgets
25
+ pip install bec_widgets
26
26
  ```
27
27
 
28
28
  For development purposes, you can clone the repository and install the package locally in editable mode:
29
29
 
30
30
  ```bash
31
31
  git clone https://gitlab.psi.ch/bec/bec-widgets
32
- cd bec-widgets
32
+ cd bec_widgets
33
33
  pip install -e .[dev]
34
34
  ```
35
35
 
@@ -38,12 +38,12 @@ BEC Widgets currently supports both PyQt5 and PyQt6. By default, PyQt6 is instal
38
38
  To select a specific Python Qt distribution, install the package with an additional tag:
39
39
 
40
40
  ```bash
41
- pip install bec-widgets[pyqt6]
41
+ pip install bec_widgets[pyqt6]
42
42
  ```
43
43
  or
44
44
 
45
45
  ```bash
46
- pip install bec-widgets[pyqt5]
46
+ pip install bec_widgets[pyqt5]
47
47
  ```
48
48
  ## Documentation
49
49
 
@@ -6,14 +6,14 @@ BEC Widgets is a GUI framework designed for interaction with [BEC (Beamline Expe
6
6
  Use the package manager [pip](https://pip.pypa.io/en/stable/) to install BEC Widgets:
7
7
 
8
8
  ```bash
9
- pip install bec-widgets
9
+ pip install bec_widgets
10
10
  ```
11
11
 
12
12
  For development purposes, you can clone the repository and install the package locally in editable mode:
13
13
 
14
14
  ```bash
15
15
  git clone https://gitlab.psi.ch/bec/bec-widgets
16
- cd bec-widgets
16
+ cd bec_widgets
17
17
  pip install -e .[dev]
18
18
  ```
19
19
 
@@ -22,12 +22,12 @@ BEC Widgets currently supports both PyQt5 and PyQt6. By default, PyQt6 is instal
22
22
  To select a specific Python Qt distribution, install the package with an additional tag:
23
23
 
24
24
  ```bash
25
- pip install bec-widgets[pyqt6]
25
+ pip install bec_widgets[pyqt6]
26
26
  ```
27
27
  or
28
28
 
29
29
  ```bash
30
- pip install bec-widgets[pyqt5]
30
+ pip install bec_widgets[pyqt5]
31
31
  ```
32
32
  ## Documentation
33
33
 
@@ -129,7 +129,15 @@ class BECDispatcher:
129
129
  self._slots[slot].update(set(topics_str))
130
130
 
131
131
  def disconnect_slot(self, slot: Callable, topics: Union[str, list]):
132
- self.client.connector.unregister(topics, cb=slot)
132
+ # find the right slot to disconnect from ;
133
+ # slot callbacks are wrapped in QtThreadSafeCallback objects,
134
+ # but the slot we receive here is the original callable
135
+ for connected_slot in self._slots:
136
+ if connected_slot.cb == slot:
137
+ break
138
+ else:
139
+ return
140
+ self.client.connector.unregister(topics, cb=connected_slot)
133
141
  topics_str, _ = self.client.connector._convert_endpointinfo(topics)
134
142
  self._slots[slot].difference_update(set(topics_str))
135
143
  if not self._slots[slot]:
@@ -0,0 +1,40 @@
1
+ import inspect
2
+
3
+ from bec_lib.plugin_helper import _get_available_plugins
4
+
5
+ from bec_widgets.utils import BECConnector
6
+
7
+
8
+ def get_plugin_widgets() -> dict[str, BECConnector]:
9
+ """
10
+ Get all available widgets from the plugin directory. Widgets are classes that inherit from BECConnector.
11
+ The plugins are provided through python plugins and specified in the respective pyproject.toml file using
12
+ the following key:
13
+
14
+ [project.entry-points."bec.widgets.user_widgets"]
15
+ plugin_widgets = "path.to.plugin.module"
16
+
17
+ e.g.
18
+ [project.entry-points."bec.widgets.user_widgets"]
19
+ plugin_widgets = "pxiii_bec.bec_widgets.widgets"
20
+
21
+ assuming that the widgets module for the package pxiii_bec is located at pxiii_bec/bec_widgets/widgets and
22
+ contains the widgets to be loaded within the pxiii_bec/bec_widgets/widgets/__init__.py file.
23
+
24
+ Returns:
25
+ dict[str, BECConnector]: A dictionary of widget names and their respective classes.
26
+ """
27
+ modules = _get_available_plugins("bec.widgets.user_widgets")
28
+ loaded_plugins = {}
29
+ print(modules)
30
+ for module in modules:
31
+ mods = inspect.getmembers(module, predicate=_filter_plugins)
32
+ for name, mod_cls in mods:
33
+ if name in loaded_plugins:
34
+ print(f"Duplicated widgets plugin {name}.")
35
+ loaded_plugins[name] = mod_cls
36
+ return loaded_plugins
37
+
38
+
39
+ def _filter_plugins(obj):
40
+ return inspect.isclass(obj) and issubclass(obj, BECConnector)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bec-widgets
3
- Version: 0.50.1
3
+ Version: 0.51.0
4
4
  Summary: BEC Widgets
5
5
  Home-page: https://gitlab.psi.ch/bec/bec-widgets
6
6
  Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec-widgets/issues
@@ -22,14 +22,14 @@ BEC Widgets is a GUI framework designed for interaction with [BEC (Beamline Expe
22
22
  Use the package manager [pip](https://pip.pypa.io/en/stable/) to install BEC Widgets:
23
23
 
24
24
  ```bash
25
- pip install bec-widgets
25
+ pip install bec_widgets
26
26
  ```
27
27
 
28
28
  For development purposes, you can clone the repository and install the package locally in editable mode:
29
29
 
30
30
  ```bash
31
31
  git clone https://gitlab.psi.ch/bec/bec-widgets
32
- cd bec-widgets
32
+ cd bec_widgets
33
33
  pip install -e .[dev]
34
34
  ```
35
35
 
@@ -38,12 +38,12 @@ BEC Widgets currently supports both PyQt5 and PyQt6. By default, PyQt6 is instal
38
38
  To select a specific Python Qt distribution, install the package with an additional tag:
39
39
 
40
40
  ```bash
41
- pip install bec-widgets[pyqt6]
41
+ pip install bec_widgets[pyqt6]
42
42
  ```
43
43
  or
44
44
 
45
45
  ```bash
46
- pip install bec-widgets[pyqt5]
46
+ pip install bec_widgets[pyqt5]
47
47
  ```
48
48
  ## Documentation
49
49
 
@@ -41,6 +41,7 @@ setup.py
41
41
  ./bec_widgets/utils/crosshair.py
42
42
  ./bec_widgets/utils/ctrl_c.py
43
43
  ./bec_widgets/utils/entry_validator.py
44
+ ./bec_widgets/utils/plugin_utils.py
44
45
  ./bec_widgets/utils/rpc_decorator.py
45
46
  ./bec_widgets/utils/thread_checker.py
46
47
  ./bec_widgets/utils/validator_delegate.py
@@ -1,7 +1,6 @@
1
1
  pydantic
2
2
  qtconsole
3
- PyQt6-Qt6<=6.6.3
4
- PyQt6<=6.6.3
3
+ PyQt6>=6.7
5
4
  jedi
6
5
  qtpy
7
6
  pyqtgraph
@@ -19,9 +18,10 @@ coverage
19
18
  pytest-qt
20
19
  black
21
20
  isort
21
+ fakeredis
22
22
 
23
23
  [pyqt5]
24
24
  PyQt5>=5.9
25
25
 
26
26
  [pyqt6]
27
- PyQt6<=6.6.3
27
+ PyQt6>=6.7
@@ -1,10 +1,10 @@
1
1
  # pylint: disable= missing-module-docstring
2
2
  from setuptools import find_packages, setup
3
3
 
4
- __version__ = "0.50.1"
4
+ __version__ = "0.51.0"
5
5
 
6
6
  # Default to PyQt6 if no other Qt binding is installed
7
- QT_DEPENDENCY = "PyQt6<=6.6.3"
7
+ QT_DEPENDENCY = "PyQt6>=6.7"
8
8
 
9
9
  # pylint: disable=unused-import
10
10
  try:
@@ -19,7 +19,6 @@ if __name__ == "__main__":
19
19
  install_requires=[
20
20
  "pydantic",
21
21
  "qtconsole",
22
- "PyQt6-Qt6<=6.6.3",
23
22
  QT_DEPENDENCY,
24
23
  "jedi",
25
24
  "qtpy",
@@ -39,9 +38,10 @@ if __name__ == "__main__":
39
38
  "pytest-qt",
40
39
  "black",
41
40
  "isort",
41
+ "fakeredis",
42
42
  ],
43
43
  "pyqt5": ["PyQt5>=5.9"],
44
- "pyqt6": ["PyQt6<=6.6.3"],
44
+ "pyqt6": ["PyQt6>=6.7"],
45
45
  },
46
46
  version=__version__,
47
47
  packages=find_packages(),
@@ -0,0 +1,140 @@
1
+ # pylint: disable = no-name-in-module,missing-class-docstring, missing-module-docstring
2
+ import threading
3
+ import time
4
+ from unittest import mock
5
+
6
+ import pytest
7
+ import redis
8
+ from bec_lib.connector import MessageObject
9
+ from bec_lib.messages import ScanMessage
10
+ from bec_lib.redis_connector import RedisConnector
11
+ from bec_lib.serialization import MsgpackSerialization
12
+
13
+ from bec_widgets.utils.bec_dispatcher import QtRedisConnector
14
+
15
+
16
+ @pytest.fixture
17
+ def bec_dispatcher_w_connector(bec_dispatcher, topics_msg_list, send_msg_event):
18
+ def pubsub_msg_generator():
19
+ send_msg_event.wait()
20
+ for topic, msg in topics_msg_list:
21
+ yield {"channel": topic.encode(), "pattern": None, "data": msg}
22
+ while True:
23
+ time.sleep(0.2)
24
+ yield StopIteration
25
+
26
+ with mock.patch("redis.Redis"):
27
+ pubsub = redis.Redis().pubsub()
28
+ messages = pubsub_msg_generator()
29
+ pubsub.get_message.side_effect = lambda timeout: next(messages)
30
+ connector = QtRedisConnector("localhost:1")
31
+ bec_dispatcher.client.connector = connector
32
+ yield bec_dispatcher
33
+
34
+
35
+ dummy_msg = MsgpackSerialization.dumps(ScanMessage(point_id=0, scan_id="0", data={}))
36
+
37
+
38
+ @pytest.fixture
39
+ def send_msg_event():
40
+ return threading.Event()
41
+
42
+
43
+ @pytest.mark.parametrize(
44
+ "topics_msg_list",
45
+ [
46
+ (
47
+ ("topic1", dummy_msg),
48
+ ("topic2", dummy_msg),
49
+ ("topic3", dummy_msg),
50
+ )
51
+ ],
52
+ )
53
+ def test_dispatcher_disconnect_all(bec_dispatcher_w_connector, qtbot, send_msg_event):
54
+ bec_dispatcher = bec_dispatcher_w_connector
55
+ cb1 = mock.Mock(spec=[])
56
+ cb2 = mock.Mock(spec=[])
57
+
58
+ bec_dispatcher.connect_slot(cb1, "topic1")
59
+ bec_dispatcher.connect_slot(cb1, "topic2")
60
+ bec_dispatcher.connect_slot(cb2, "topic2")
61
+ bec_dispatcher.connect_slot(cb2, "topic3")
62
+ assert len(bec_dispatcher.client.connector._topics_cb) == 3
63
+ send_msg_event.set()
64
+ qtbot.wait(10)
65
+ assert cb1.call_count == 2
66
+ assert cb2.call_count == 2
67
+
68
+ bec_dispatcher.disconnect_all()
69
+
70
+ assert len(bec_dispatcher.client.connector._topics_cb) == 0
71
+
72
+
73
+ @pytest.mark.parametrize(
74
+ "topics_msg_list",
75
+ [
76
+ (
77
+ ("topic1", dummy_msg),
78
+ ("topic2", dummy_msg),
79
+ )
80
+ ],
81
+ )
82
+ def test_dispatcher_disconnect_one(bec_dispatcher_w_connector, qtbot, send_msg_event):
83
+ # test for BEC issue #276
84
+ bec_dispatcher = bec_dispatcher_w_connector
85
+ cb1 = mock.Mock(spec=[])
86
+ cb2 = mock.Mock(spec=[])
87
+
88
+ bec_dispatcher.connect_slot(cb1, "topic1")
89
+ bec_dispatcher.connect_slot(cb2, "topic2")
90
+ assert len(bec_dispatcher.client.connector._topics_cb) == 2
91
+ bec_dispatcher.disconnect_slot(cb1, "topic1")
92
+ assert len(bec_dispatcher.client.connector._topics_cb) == 1
93
+
94
+ send_msg_event.set()
95
+ qtbot.wait(10)
96
+ assert cb1.call_count == 0
97
+ cb2.assert_called_once()
98
+
99
+
100
+ @pytest.mark.parametrize("topics_msg_list", [(("topic1", dummy_msg),)])
101
+ def test_dispatcher_2_cb_same_topic(bec_dispatcher_w_connector, qtbot, send_msg_event):
102
+ # test for BEC issue #276
103
+ bec_dispatcher = bec_dispatcher_w_connector
104
+ cb1 = mock.Mock(spec=[])
105
+ cb2 = mock.Mock(spec=[])
106
+
107
+ bec_dispatcher.connect_slot(cb1, "topic1")
108
+ bec_dispatcher.connect_slot(cb2, "topic1")
109
+ assert len(bec_dispatcher.client.connector._topics_cb) == 1
110
+ bec_dispatcher.disconnect_slot(cb1, "topic1")
111
+
112
+ send_msg_event.set()
113
+ qtbot.wait(10)
114
+ assert cb1.call_count == 0
115
+ cb2.assert_called_once()
116
+
117
+
118
+ @pytest.mark.parametrize(
119
+ "topics_msg_list",
120
+ [
121
+ (
122
+ ("topic1", dummy_msg),
123
+ ("topic2", dummy_msg),
124
+ )
125
+ ],
126
+ )
127
+ def test_dispatcher_2_topic_same_cb(bec_dispatcher_w_connector, qtbot, send_msg_event):
128
+ # test for BEC issue #276
129
+ bec_dispatcher = bec_dispatcher_w_connector
130
+ cb1 = mock.Mock(spec=[])
131
+
132
+ bec_dispatcher.connect_slot(cb1, "topic1")
133
+ bec_dispatcher.connect_slot(cb1, "topic2")
134
+ assert len(bec_dispatcher.client.connector._topics_cb) == 2
135
+ bec_dispatcher.disconnect_slot(cb1, "topic1")
136
+ assert len(bec_dispatcher.client.connector._topics_cb) == 1
137
+
138
+ send_msg_event.set()
139
+ qtbot.wait(10)
140
+ cb1.assert_called_once()
@@ -1,59 +0,0 @@
1
- # pylint: disable = no-name-in-module,missing-class-docstring, missing-module-docstring
2
- import time
3
- from unittest import mock
4
-
5
- import pytest
6
- import redis
7
- from bec_lib.connector import MessageObject
8
- from bec_lib.messages import ScanMessage
9
- from bec_lib.redis_connector import RedisConnector
10
- from bec_lib.serialization import MsgpackSerialization
11
-
12
- from bec_widgets.utils.bec_dispatcher import QtRedisConnector
13
-
14
-
15
- @pytest.fixture
16
- def bec_dispatcher_w_connector(bec_dispatcher, topics_msg_list):
17
- def pubsub_msg_generator():
18
- for topic, msg in topics_msg_list:
19
- yield {"channel": topic.encode(), "pattern": None, "data": msg}
20
- while True:
21
- time.sleep(0.2)
22
- yield StopIteration
23
-
24
- with mock.patch("redis.Redis"):
25
- pubsub = redis.Redis().pubsub()
26
- messages = pubsub_msg_generator()
27
- pubsub.get_message.side_effect = lambda timeout: next(messages)
28
- connector = QtRedisConnector("localhost:1")
29
- bec_dispatcher.client.connector = connector
30
- yield bec_dispatcher
31
-
32
-
33
- dummy_msg = MsgpackSerialization.dumps(ScanMessage(point_id=0, scan_id="0", data={}))
34
-
35
-
36
- @pytest.mark.parametrize(
37
- "topics_msg_list",
38
- [
39
- (
40
- ("topic1", dummy_msg),
41
- ("topic2", dummy_msg),
42
- ("topic3", dummy_msg),
43
- )
44
- ],
45
- )
46
- def test_dispatcher_disconnect_all(bec_dispatcher_w_connector, qtbot):
47
- bec_dispatcher = bec_dispatcher_w_connector
48
- cb1 = mock.Mock(spec=[])
49
- cb2 = mock.Mock(spec=[])
50
-
51
- bec_dispatcher.connect_slot(cb1, "topic1")
52
- bec_dispatcher.connect_slot(cb1, "topic2")
53
- bec_dispatcher.connect_slot(cb2, "topic2")
54
- bec_dispatcher.connect_slot(cb2, "topic3")
55
- assert len(bec_dispatcher.client.connector._topics_cb) == 3
56
-
57
- bec_dispatcher.disconnect_all()
58
-
59
- assert len(bec_dispatcher.client.connector._topics_cb) == 0
File without changes
File without changes