pytest-bec-e2e 3.47.1__py3-none-any.whl → 3.88.1__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.
.gitignore CHANGED
@@ -9,6 +9,9 @@
9
9
  **/*.egg*
10
10
  **/*.env
11
11
 
12
+ # bec_widgets saved profiles
13
+ widgets_settings/profiles/*
14
+
12
15
  # recovery_config files
13
16
  recovery_config_*
14
17
 
PKG-INFO CHANGED
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-bec-e2e
3
- Version: 3.47.1
3
+ Version: 3.88.1
4
4
  Summary: BEC pytest plugin for end-to-end tests
5
5
  Project-URL: Bug Tracker, https://github.com/bec-project/bec/issues
6
6
  Project-URL: Homepage, https://github.com/bec-project/bec
7
7
  Classifier: Development Status :: 3 - Alpha
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Topic :: Scientific/Engineering
10
- Requires-Python: >=3.10
10
+ Requires-Python: >=3.11
11
11
  Requires-Dist: bec-ipython-client
12
12
  Requires-Dist: bec-lib
13
13
  Requires-Dist: bec-server
pyproject.toml CHANGED
@@ -4,9 +4,9 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pytest-bec-e2e"
7
- version = "3.47.1"
7
+ version = "3.88.1"
8
8
  description = "BEC pytest plugin for end-to-end tests"
9
- requires-python = ">=3.10"
9
+ requires-python = ">=3.11"
10
10
  classifiers = [
11
11
  "Development Status :: 3 - Alpha",
12
12
  "Programming Language :: Python :: 3",
pytest_bec_e2e/plugin.py CHANGED
@@ -14,10 +14,48 @@ from redis import Redis
14
14
  from bec_ipython_client import BECIPythonClient
15
15
  from bec_lib.client import BECClient
16
16
  from bec_lib.config_helper import ConfigHelper
17
+ from bec_lib.endpoints import MessageEndpoints
17
18
  from bec_lib.redis_connector import RedisConnector
18
- from bec_lib.service_config import ServiceConfig
19
+ from bec_lib.service_config import ServiceConfig, ServiceConfigModel
19
20
  from bec_lib.tests.utils import wait_for_empty_queue
20
21
 
22
+ RedisConnector.RETRY_ON_TIMEOUT = 1
23
+
24
+
25
+ class LogTestTool:
26
+ def __init__(self, client: BECIPythonClient):
27
+ self._conn: RedisConnector = client.connector
28
+ self._logs = None
29
+
30
+ def fetch(self, count: int | None = None) -> None:
31
+ """Fetch logs from the server and store them for interrogation, get all by default or get
32
+ the last `count` logs (latter will not fetch read logs again if they have been seen!)"""
33
+ log_data = self._conn.xread(MessageEndpoints.log(), from_start=(count is None), count=count)
34
+ if log_data is None:
35
+ self._logs = None
36
+ return
37
+ self._logs = list(item["data"].log_msg["text"] for item in log_data)
38
+
39
+ def is_present_in_any_message(self, needle: str) -> bool:
40
+ """Assert that the provided string is in at least one log message"""
41
+ if self._logs is None:
42
+ raise RuntimeError("No logs fetched")
43
+ for log in self._logs:
44
+ if needle in log:
45
+ return True
46
+ return False
47
+
48
+ def are_present_in_order(self, needles: list[str]) -> tuple[bool, str]:
49
+ if self._logs is None:
50
+ raise RuntimeError("No logs fetched")
51
+ _needles = list(reversed(needles.copy()))
52
+ for log in self._logs:
53
+ if _needles[-1] in log:
54
+ _needles.pop()
55
+ if len(_needles) == 0:
56
+ return True, ""
57
+ return False, _needles[0]
58
+
21
59
 
22
60
  @pytest.hookimpl
23
61
  def pytest_addoption(parser):
@@ -35,27 +73,6 @@ bec_servers_scope = (
35
73
  lambda fixture_name, config: config.getoption("--flush-redis") and "function" or "session"
36
74
  )
37
75
 
38
- services_config_template = """
39
- redis:
40
- host: %(redis_host)s
41
- port: %(redis_port)s
42
- mongodb:
43
- host: "localhost"
44
- port: 27017
45
- scibec:
46
- host: http://localhost
47
- port: 3030
48
- beamline: TestBeamline
49
- service_config:
50
- abort_on_ctrl_c: False
51
- enforce_ACLs: False
52
- file_writer:
53
- plugin: default_NeXus_format
54
- base_path: %(file_writer_base_path)s
55
- log_writer:
56
- base_path: %(file_writer_base_path)s
57
- """
58
-
59
76
 
60
77
  def _check_path(file_path):
61
78
  if os.path.exists(file_path):
@@ -165,15 +182,13 @@ def bec_servers(
165
182
  # file_writer_path.mkdir(exist_ok=True)
166
183
  # 3) services config
167
184
  with open(bec_services_config_file_path, "w") as services_config_file:
168
- services_config_file.write(
169
- services_config_template
170
- % {
171
- "redis_host": redis_host,
172
- "redis_port": redis_port,
173
- "file_writer_base_path": file_writer_path,
174
- }
185
+ service_config = ServiceConfigModel(
186
+ redis={"host": redis_host, "port": redis_port},
187
+ file_writer={"base_path": str(file_writer_path)},
175
188
  )
176
189
 
190
+ services_config_file.write(service_config.model_dump_json(indent=4))
191
+
177
192
  if _start_servers:
178
193
  from bec_server.bec_server_utils.service_handler import ServiceHandler
179
194
 
@@ -202,7 +217,7 @@ def bec_ipython_client_with_demo_config(
202
217
  config = ServiceConfig(bec_services_config_file_path)
203
218
  bec = BECIPythonClient(config, RedisConnector, forced=True)
204
219
  bec.start()
205
- bec.config.load_demo_config()
220
+ bec.config.load_demo_config(force=True)
206
221
  try:
207
222
  yield bec
208
223
  finally:
@@ -215,7 +230,7 @@ def bec_client_lib_with_demo_config(bec_redis_fixture, bec_services_config_file_
215
230
  config = ServiceConfig(bec_services_config_file_path)
216
231
  bec = BECClient(config, RedisConnector, forced=True, wait_for_server=True)
217
232
  bec.start()
218
- bec.config.load_demo_config()
233
+ bec.config.load_demo_config(force=True)
219
234
  try:
220
235
  yield bec
221
236
  finally:
@@ -239,3 +254,9 @@ def bec_client_lib(bec_client_lib_with_demo_config):
239
254
  bec.queue.request_scan_continuation()
240
255
  wait_for_empty_queue(bec)
241
256
  yield bec
257
+
258
+
259
+ @pytest.fixture
260
+ def bec_ipython_client_fixture_with_logtool(bec_ipython_client_fixture):
261
+ bec: BECIPythonClient = bec_ipython_client_fixture
262
+ yield bec, LogTestTool(bec)
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-bec-e2e
3
- Version: 3.47.1
3
+ Version: 3.88.1
4
4
  Summary: BEC pytest plugin for end-to-end tests
5
5
  Project-URL: Bug Tracker, https://github.com/bec-project/bec/issues
6
6
  Project-URL: Homepage, https://github.com/bec-project/bec
7
7
  Classifier: Development Status :: 3 - Alpha
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Topic :: Scientific/Engineering
10
- Requires-Python: >=3.10
10
+ Requires-Python: >=3.11
11
11
  Requires-Dist: bec-ipython-client
12
12
  Requires-Dist: bec-lib
13
13
  Requires-Dist: bec-server
@@ -0,0 +1,9 @@
1
+ .gitignore,sha256=XxC6jyyftTo2CLtm4K8axuNPYwA9Wgaz2R93WhX8bTQ,3364
2
+ PKG-INFO,sha256=DsN1ifaZzbO-wZS_6-JTmaw3PumGAtGvFqT93fUXjHo,526
3
+ pyproject.toml,sha256=74TLXBKIIjeZcOEPiYEySY63zC2apc0S8T6Epc-aqiA,780
4
+ pytest_bec_e2e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pytest_bec_e2e/plugin.py,sha256=0KuhFYYZGRy_j9ZwaNPGgMI-Bt_o9KCyaXlcdsUjfcY,9483
6
+ pytest_bec_e2e-3.88.1.dist-info/METADATA,sha256=DsN1ifaZzbO-wZS_6-JTmaw3PumGAtGvFqT93fUXjHo,526
7
+ pytest_bec_e2e-3.88.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
8
+ pytest_bec_e2e-3.88.1.dist-info/entry_points.txt,sha256=FLvRZqsjOQkvTOuo9A2kiyG9vMBia2sXREgVHb35DXA,56
9
+ pytest_bec_e2e-3.88.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,9 +0,0 @@
1
- .gitignore,sha256=UmJ0gTRAPp4EI1A6tb9Pi-k5uxDIb_NWJU9ye6AW-8Y,3306
2
- PKG-INFO,sha256=tYsfggjzwM0RWc6ohwi8gq9hWb66TZ-Zyxn1uqDRGfc,526
3
- pyproject.toml,sha256=OWl-0WuM9_Mo-UUcXGAig6kJ7O-U5q2Umqf4DbnCmro,780
4
- pytest_bec_e2e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- pytest_bec_e2e/plugin.py,sha256=ukIzIC0ebt2YC1p7TCcDqxKNDfHmATXvtTfAwyxKILI,8196
6
- pytest_bec_e2e-3.47.1.dist-info/METADATA,sha256=tYsfggjzwM0RWc6ohwi8gq9hWb66TZ-Zyxn1uqDRGfc,526
7
- pytest_bec_e2e-3.47.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- pytest_bec_e2e-3.47.1.dist-info/entry_points.txt,sha256=FLvRZqsjOQkvTOuo9A2kiyG9vMBia2sXREgVHb35DXA,56
9
- pytest_bec_e2e-3.47.1.dist-info/RECORD,,