pytest-bec-e2e 3.61.0__py3-none-any.whl → 3.62.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.

Potentially problematic release.


This version of pytest-bec-e2e might be problematic. Click here for more details.

PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-bec-e2e
3
- Version: 3.61.0
3
+ Version: 3.62.0
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
pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pytest-bec-e2e"
7
- version = "3.61.0"
7
+ version = "3.62.0"
8
8
  description = "BEC pytest plugin for end-to-end tests"
9
9
  requires-python = ">=3.10"
10
10
  classifiers = [
pytest_bec_e2e/plugin.py CHANGED
@@ -14,11 +14,47 @@ 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
19
  from bec_lib.service_config import ServiceConfig, ServiceConfigModel
19
20
  from bec_lib.tests.utils import wait_for_empty_queue
20
21
 
21
22
 
23
+ class LogTestTool:
24
+ def __init__(self, client: BECIPythonClient):
25
+ self._conn: RedisConnector = client.connector
26
+ self._logs = None
27
+
28
+ def fetch(self, count: int | None = None) -> None:
29
+ """Fetch logs from the server and store them for interrogation, get all by default or get
30
+ the last `count` logs (latter will not fetch read logs again if they have been seen!)"""
31
+ log_data = self._conn.xread(MessageEndpoints.log(), from_start=(count is None), count=count)
32
+ if log_data is None:
33
+ self._logs = None
34
+ return
35
+ self._logs = list(item["data"].log_msg["text"] for item in log_data)
36
+
37
+ def is_present_in_any_message(self, needle: str) -> bool:
38
+ """Assert that the provided string is in at least one log message"""
39
+ if self._logs is None:
40
+ raise RuntimeError("No logs fetched")
41
+ for log in self._logs:
42
+ if needle in log:
43
+ return True
44
+ return False
45
+
46
+ def are_present_in_order(self, needles: list[str]) -> tuple[bool, str]:
47
+ if self._logs is None:
48
+ raise RuntimeError("No logs fetched")
49
+ _needles = list(reversed(needles.copy()))
50
+ for log in self._logs:
51
+ if _needles[-1] in log:
52
+ _needles.pop()
53
+ if len(_needles) == 0:
54
+ return True, ""
55
+ return False, _needles[0]
56
+
57
+
22
58
  @pytest.hookimpl
23
59
  def pytest_addoption(parser):
24
60
  parser.addoption("--start-servers", action="store_true", default=False)
@@ -216,3 +252,9 @@ def bec_client_lib(bec_client_lib_with_demo_config):
216
252
  bec.queue.request_scan_continuation()
217
253
  wait_for_empty_queue(bec)
218
254
  yield bec
255
+
256
+
257
+ @pytest.fixture
258
+ def bec_ipython_client_fixture_with_logtool(bec_ipython_client_fixture):
259
+ bec: BECIPythonClient = bec_ipython_client_fixture
260
+ yield bec, LogTestTool(bec)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-bec-e2e
3
- Version: 3.61.0
3
+ Version: 3.62.0
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
@@ -0,0 +1,9 @@
1
+ .gitignore,sha256=UmJ0gTRAPp4EI1A6tb9Pi-k5uxDIb_NWJU9ye6AW-8Y,3306
2
+ PKG-INFO,sha256=hgk5be0eUzdeu2sE7WCkzoytkSLiQknDKcnCi5lUAbI,526
3
+ pyproject.toml,sha256=JW96fmNukh5iFgNTseD6kaYmVag2t26a7okrpRMZz98,780
4
+ pytest_bec_e2e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pytest_bec_e2e/plugin.py,sha256=YdALungShHFvfflRViPTdz-lIl6H3JbYPxDhWsPKCkg,9426
6
+ pytest_bec_e2e-3.62.0.dist-info/METADATA,sha256=hgk5be0eUzdeu2sE7WCkzoytkSLiQknDKcnCi5lUAbI,526
7
+ pytest_bec_e2e-3.62.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ pytest_bec_e2e-3.62.0.dist-info/entry_points.txt,sha256=FLvRZqsjOQkvTOuo9A2kiyG9vMBia2sXREgVHb35DXA,56
9
+ pytest_bec_e2e-3.62.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- .gitignore,sha256=UmJ0gTRAPp4EI1A6tb9Pi-k5uxDIb_NWJU9ye6AW-8Y,3306
2
- PKG-INFO,sha256=pY9szDetQtebx6RmXFMmnO3aUN4om6PoD7BYzGDvrSg,526
3
- pyproject.toml,sha256=nEEEFV0JJgMQdRD_9SlY-s2OKIXdLkUE3kmTZUlyYtA,780
4
- pytest_bec_e2e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- pytest_bec_e2e/plugin.py,sha256=km5iSHjy3dzmGj3PnL0dOlEZAPo3l-vSu8Gn0vy36a4,7805
6
- pytest_bec_e2e-3.61.0.dist-info/METADATA,sha256=pY9szDetQtebx6RmXFMmnO3aUN4om6PoD7BYzGDvrSg,526
7
- pytest_bec_e2e-3.61.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- pytest_bec_e2e-3.61.0.dist-info/entry_points.txt,sha256=FLvRZqsjOQkvTOuo9A2kiyG9vMBia2sXREgVHb35DXA,56
9
- pytest_bec_e2e-3.61.0.dist-info/RECORD,,