userver: /home/antonyzhilin/arcadia/taxi/uservices/userver/libraries/grpc-reflection/functional_tests/golden_path/tests/conftest.py Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
conftest.py
1import pathlib
2import tempfile
3
4from grpc_reflection.v1alpha.proto_reflection_descriptor_database import ServerReflectionStub
5import pytest
6
7pytest_plugins = ['pytest_userver.plugins.grpc']
8
9USERVER_CONFIG_HOOKS = ['prepare_service_config']
10
11
12@pytest.fixture(scope='session')
13def unix_socket_path(tmp_path_factory) -> pathlib.Path:
14 with tempfile.TemporaryDirectory(prefix='userver-grpc-socket-') as name:
15 yield pathlib.Path(name) / 's'
16
17
18@pytest.fixture(scope='session')
19def grpc_service_endpoint(service_config) -> str:
20 components = service_config['components_manager']['components']
21 return f'unix:{components["grpc-server"]["unix-socket-path"]}'
22
23
24@pytest.fixture(name='prepare_service_config', scope='session')
25def _prepare_service_config(unix_socket_path):
26 def patch_config(config, config_vars):
27 components = config['components_manager']['components']
28 components['grpc-server']['unix-socket-path'] = str(unix_socket_path)
29
30 return patch_config
31
32
33@pytest.fixture
34def grpc_reflection_client(grpc_channel, service_client):
35 return ServerReflectionStub(grpc_channel)