pytest-bec-e2e 3.47.1__py3-none-any.whl → 3.74.2__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.
- PKG-INFO +2 -2
- pyproject.toml +2 -2
- pytest_bec_e2e/plugin.py +48 -29
- {pytest_bec_e2e-3.47.1.dist-info → pytest_bec_e2e-3.74.2.dist-info}/METADATA +2 -2
- pytest_bec_e2e-3.74.2.dist-info/RECORD +9 -0
- pytest_bec_e2e-3.47.1.dist-info/RECORD +0 -9
- {pytest_bec_e2e-3.47.1.dist-info → pytest_bec_e2e-3.74.2.dist-info}/WHEEL +0 -0
- {pytest_bec_e2e-3.47.1.dist-info → pytest_bec_e2e-3.74.2.dist-info}/entry_points.txt +0 -0
PKG-INFO
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-bec-e2e
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.74.2
|
|
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
|
+
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.
|
|
7
|
+
version = "3.74.2"
|
|
8
8
|
description = "BEC pytest plugin for end-to-end tests"
|
|
9
|
-
requires-python = ">=3.
|
|
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,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
|
-
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
|
|
|
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)
|
|
@@ -35,27 +71,6 @@ bec_servers_scope = (
|
|
|
35
71
|
lambda fixture_name, config: config.getoption("--flush-redis") and "function" or "session"
|
|
36
72
|
)
|
|
37
73
|
|
|
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
74
|
|
|
60
75
|
def _check_path(file_path):
|
|
61
76
|
if os.path.exists(file_path):
|
|
@@ -165,15 +180,13 @@ def bec_servers(
|
|
|
165
180
|
# file_writer_path.mkdir(exist_ok=True)
|
|
166
181
|
# 3) services config
|
|
167
182
|
with open(bec_services_config_file_path, "w") as services_config_file:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
"redis_host": redis_host,
|
|
172
|
-
"redis_port": redis_port,
|
|
173
|
-
"file_writer_base_path": file_writer_path,
|
|
174
|
-
}
|
|
183
|
+
service_config = ServiceConfigModel(
|
|
184
|
+
redis={"host": redis_host, "port": redis_port},
|
|
185
|
+
file_writer={"base_path": str(file_writer_path)},
|
|
175
186
|
)
|
|
176
187
|
|
|
188
|
+
services_config_file.write(service_config.model_dump_json(indent=4))
|
|
189
|
+
|
|
177
190
|
if _start_servers:
|
|
178
191
|
from bec_server.bec_server_utils.service_handler import ServiceHandler
|
|
179
192
|
|
|
@@ -239,3 +252,9 @@ def bec_client_lib(bec_client_lib_with_demo_config):
|
|
|
239
252
|
bec.queue.request_scan_continuation()
|
|
240
253
|
wait_for_empty_queue(bec)
|
|
241
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,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-bec-e2e
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.74.2
|
|
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
|
+
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=UmJ0gTRAPp4EI1A6tb9Pi-k5uxDIb_NWJU9ye6AW-8Y,3306
|
|
2
|
+
PKG-INFO,sha256=PKnYHcy9DVkrUGAyJkFKwqajIwV5DrLrpFK8zzq3dr8,526
|
|
3
|
+
pyproject.toml,sha256=_AWdDeJXuosmIN_xT-a7LxjcEo_8043pre79v4AAc-M,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.74.2.dist-info/METADATA,sha256=PKnYHcy9DVkrUGAyJkFKwqajIwV5DrLrpFK8zzq3dr8,526
|
|
7
|
+
pytest_bec_e2e-3.74.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8
|
+
pytest_bec_e2e-3.74.2.dist-info/entry_points.txt,sha256=FLvRZqsjOQkvTOuo9A2kiyG9vMBia2sXREgVHb35DXA,56
|
|
9
|
+
pytest_bec_e2e-3.74.2.dist-info/RECORD,,
|
|
@@ -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,,
|
|
File without changes
|
|
File without changes
|