userver: /data/code/userver/testsuite/pytest_plugins/pytest_userver/grpc/__init__.py Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
__init__.py
1"""
2Mocks for the gRPC servers.
3
4@sa @ref scripts/docs/en/userver/tutorial/grpc_service.md
5@sa @ref pytest_userver.plugins.grpc.mockserver
6"""
7
8import grpc # noqa # pylint: disable=unused-import
9
10
11class MockedError(Exception):
12 """
13 @brief Base class for mocked exceptions.
14 @alias pytest_userver.grpc.MockedError
15 """
16
17 ERROR_CODE = 'unknown'
18
19
20class TimeoutError(MockedError): # pylint: disable=redefined-builtin
21 """
22 @brief When thrown from a mocked handler, leads to `ugrpc::client::RpcInterruptedError`.
23 @alias pytest_userver.grpc.TimeoutError
24 """
25
26 ERROR_CODE = 'timeout'
27
28
30 """
31 @brief When thrown from a mocked handler, leads to `ugrpc::client::RpcInterruptedError`.
32 @alias pytest_userver.grpc.NetworkError
33 """
34
35 ERROR_CODE = 'network'