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