userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
service_runner.py
1
"""
2
Helpers to make the `make start-*` commands work.
3
"""
4
5
from
collections.abc
import
Iterable
6
from
collections.abc
import
Sequence
7
8
import
pytest
9
10
pytest_plugins = [
'pytest_userver.plugins.generated_tests'
]
11
12
13
def
pytest_generate_virtual_tests(
14
parent: pytest.File,
15
config: pytest.Config,
16
existing_items: Sequence[pytest.Item],
17
) -> Iterable[pytest.Item]:
18
if
not
config.option.service_runner_mode:
19
return
20
21
for
item
in
existing_items:
22
for
marker
in
item.own_markers:
23
if
marker.name ==
'servicetest'
:
24
return
25
26
yield
pytest.Function.from_parent(
27
parent=parent,
28
name=test_service_default.__name__,
29
callobj=test_service_default,
30
)
31
32
33
@pytest.mark.servicetest
34
def
test_service_default
(
35
service_client,
36
service_baseurl,
37
monitor_baseurl,
38
request,
39
) -> None:
40
"""
41
This is default service runner testcase. Feel free to override it
42
in your own tests, e.g.:
43
44
@code
45
@pytest.mark.servicetest
46
def test_service(service_client):
47
...
48
@endcode
49
50
@ingroup userver_testsuite
51
"""
52
# TODO: use service_client.base_url() and monitor_client.base_url()
53
delimiter =
'='
* 100
54
message = f
'\n{delimiter}\nStarted service at {service_baseurl}'
55
if
monitor_baseurl:
56
message += f
'\nMonitor URL is {monitor_baseurl}'
57
if
'grpc_service_endpoint'
in
request.fixturenames:
58
grpc_endpoint = request.getfixturevalue(
'grpc_service_endpoint'
)
59
message += f
'\ngRPC endpoint is {grpc_endpoint}'
60
message += f
'\n{delimiter}\n'
61
print(message)
testsuite
pytest_plugins
pytest_userver
plugins
service_runner.py
Generated on
for userver by
Doxygen
1.17.0