Functions, fixtures and classes to do functional testing with testsuite.
Nested Groups | |
| Fixtures | |
| Fixtures to use with testsuite. | |
Namespaces | |
| namespace | pytest_userver |
| Python module pytest_userver provides testsuite support for userver services. | |
| namespace | pytest_userver.chaos |
| Python module that provides testsuite support for chaos tests; see Chaos Testing for an introduction. | |
| namespace | pytest_userver.client |
| Python module that provides clients for functional tests with testsuite; see Functional service tests (testsuite) for an introduction. | |
| namespace | pytest_userver.dynconf |
| Python module that provides classes and constants that may be useful when working with the dynamic config in testsuite. | |
| namespace | pytest_userver.metrics |
| Python module that provides helpers for functional testing of metrics with testsuite; see Functional service tests (testsuite) for an introduction. | |
Classes | |
| class | pytest_userver.chaos.GateRoute |
| Class that describes the route for TcpGate or UdpGate. More... | |
| class | pytest_userver.chaos.BaseGate |
| This base class maintain endpoints of two types: More... | |
| class | pytest_userver.chaos.TcpGate |
| Implements TCP chaos-proxy logic such as accepting incoming tcp client connections. More... | |
| class | pytest_userver.chaos.UdpGate |
| Implements UDP chaos-proxy logic such as demuxing incoming datagrams from different clients. More... | |
| class | pytest_userver.client.ClientWrapper |
| Base asyncio userver client that implements HTTP requests to service. More... | |
| class | pytest_userver.client.ClientMonitor |
| Asyncio userver client for monitor listeners, typically retrieved from plugins.service_client.monitor_client fixture. More... | |
| class | pytest_userver.client.MetricsDiffer |
| A helper class for computing metric differences. More... | |
| class | pytest_userver.client.Client |
| Asyncio userver client, typically retrieved from plugins.service_client.service_client fixture. More... | |
| class | pytest_userver.grpc._client.PreCallClientInterceptor |
| A simple generic interceptor that allows to insert some code before each RPC is initiated. More... | |
| class | pytest_userver.metrics.Metric |
Metric type that contains the labels: dict[str, str] and value: int. More... | |
| class | pytest_userver.metrics.MetricsSnapshot |
| Snapshot of captured metrics that mimics the dict interface. More... | |
| class | pytest_userver.sql.RegisteredTrx |
| RegisteredTrx maintains transaction fault injection state to test transaction failure code path. More... | |
| class | pytest_userver.utils.net.HostPort |
| Class that holds a host and port. More... | |
| class | pytest_userver.utils.net.HealthChecks |
| Class that holds all the info for health checks. More... | |
Functions | |
| Sequence[grpc.aio.ClientInterceptor] | pytest_userver.plugins.grpc._hookspec.pytest_grpc_client_interceptors (pytest.FixtureRequest request) |
| A pytest hook that returns gRPC client interceptors to use when making requests to the service. | |
| None | pytest_userver.plugins.service_runner.test_service_default (service_client, service_baseurl, monitor_baseurl, request) |
| This is default service runner testcase. | |
| bool | pytest_userver.utils.net.check_availability (HealthChecks checks) |
| Checks availability for each provided entry. | |
| HealthChecks | pytest_userver.utils.net.get_health_checks_info (dict service_config) |
| Returns a health checks info that for server.listener, grpc-server.port and server.listener-monitor. | |
| Any | pytest_userver.utils.sync.wait_until (Callable func, *, float relax_period_seconds=ITERATION_PERIOD_SECONDS, float total_wait_seconds=TOTAL_WAIT_SECONDS) |
Waits for some external event for total_wait_seconds and calls func every relax_period_seconds. | |
| None | pytest_userver.utils.sync.wait (Callable check, *, Any|tuple catch=(), float relax_period_seconds=ITERATION_PERIOD_SECONDS, float total_wait_seconds=TOTAL_WAIT_SECONDS, str failure_msg='Timeout happened while waiting for an event', str|None relax_msg=None) |
Waits for some external event for total_wait_seconds and calls check every relax_period_seconds. | |
| bool pytest_userver.utils.net.check_availability | ( | HealthChecks | checks | ) |
| HealthChecks pytest_userver.utils.net.get_health_checks_info | ( | dict | service_config | ) |
| Sequence[grpc.aio.ClientInterceptor] pytest_userver.plugins.grpc._hookspec.pytest_grpc_client_interceptors | ( | pytest.FixtureRequest | request | ) |
A pytest hook that returns gRPC client interceptors to use when making requests to the service.
Interceptors are accomulated over all implementations of this hook from all plugins.
Definition at line 10 of file _hookspec.py.
| None pytest_userver.plugins.service_runner.test_service_default | ( | service_client, | |
| service_baseurl, | |||
| monitor_baseurl, | |||
| request ) |
This is default service runner testcase.
Feel free to override it in your own tests, e.g.:
Definition at line 61 of file service_runner.py.
| None pytest_userver.utils.sync.wait | ( | Callable | check, |
| * | , | ||
| Any | tuple | catch = (), | ||
| float | relax_period_seconds = ITERATION_PERIOD_SECONDS, | ||
| float | total_wait_seconds = TOTAL_WAIT_SECONDS, | ||
| str | failure_msg = 'Timeout happened while waiting for an event', | ||
| str | None | relax_msg = None ) |
Waits for some external event for total_wait_seconds and calls check every relax_period_seconds.
If check returns False or raises NotReady exception (or any exception type referenced in catch), the waiting continues. If check returns True, wait_until() stops and returns. After total_wait_seconds of unsuccessful checks wait_until() raises TimeoutError.
Example:
.. code-block:: python
async def is_ready():
return await conn.is_ready()
await wait_until(try_to_connect_db)
| TimeoutError | after total_wait_seconds of unsuccessful checks |
| Any pytest_userver.utils.sync.wait_until | ( | Callable | func, |
| * | , | ||
| float | relax_period_seconds = ITERATION_PERIOD_SECONDS, | ||
| float | total_wait_seconds = TOTAL_WAIT_SECONDS ) |
Waits for some external event for total_wait_seconds and calls func every relax_period_seconds.
If func raises NotReady exception, the waiting continues. If func successfully returns, wait_until() returns the same value. After total_wait_seconds of unsuccessful checks wait_until() raises TimeoutError.
Example:
.. code-block:: python
async def try_to_connect_db():
if not db_conn_is_ok():
raise NotReady()
await wait_until(try_to_connect_db)
| TimeoutError | after total_wait_seconds of unsuccessful checks |