4from grpc_reflection.v1alpha.proto_reflection_descriptor_database
import (
9pytest_plugins = [
'pytest_userver.plugins.grpc']
11USERVER_CONFIG_HOOKS = [
'prepare_service_config']
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'
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"]}'
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)
36def grpc_reflection_client(grpc_channel, service_client):
37 return ServerReflectionStub(grpc_channel)