userver: samples/tcp_full_duplex_service/tests/conftest.py
Loading...
Searching...
No Matches
samples/tcp_full_duplex_service/tests/conftest.py
1# /// [service_non_http_health_checker]
2import pytest
3from pytest_userver.utils import net
4
5
6pytest_plugins = ['pytest_userver.plugins.core']
7
8
9@pytest.fixture(name='tcp_service_port', scope='session')
10def _tcp_service_port(service_config) -> int:
11 components = service_config['components_manager']['components']
12 tcp_hello = components.get('tcp-echo')
13 assert tcp_hello, 'No "tcp-echo" component found'
14 return int(tcp_hello['port'])
15
16
17@pytest.fixture(scope='session')
18def service_non_http_health_checks(
19 service_config, tcp_service_port,
20) -> net.HealthChecks:
21 checks = net.get_health_checks_info(service_config)
22 checks.tcp.append(net.HostPort(host='localhost', port=tcp_service_port))
23 return checks
24 # /// [service_non_http_health_checker]