userver: samples/tcp_service/tests/conftest.py
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
samples/tcp_service/tests/conftest.py
1# /// [service_non_http_health_checker]
2import pytest
3from pytest_userver.utils import net
4
5pytest_plugins = ['pytest_userver.plugins.core']
6
7
8@pytest.fixture(name='tcp_service_port', scope='session')
9def _tcp_service_port(service_config) -> int:
10 components = service_config['components_manager']['components']
11 tcp_hello = components.get('tcp-hello')
12 assert tcp_hello, 'No "tcp-hello" component found'
13 return int(tcp_hello['port'])
14
15
16@pytest.fixture(scope='session')
17def service_non_http_health_checks(
18 service_config,
19 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]