grpc / grpc/grpc

Python: grpcio-testing support for server interceptors

Open
#28,214 7 comments 3 reactions 1 assignee Claimed by @gnossen View on GitHub
disposition/help wanted kind/enhancement lang/Python priority/P2
Dominant language
C++
Stars
45.3k
Forks
11.4k
Avg merge
2d 12h
Merged PRs (30d)
47

Description

### Is your feature request related to a problem? Please describe.
As far as I can tell, unit testing a gRPC server with its interceptors is not possible.

**This leads to 2 issues :**
- It is not possible to unit test servers which **require** that a specific interceptor exists (e.g. transforming the input query)
- [Possibly wrong] It is not possible to unit test the interceptors themselves

The root cause seems to be that it is not possible to pass an `interceptors` param to a test gRPC server (e.g. `grpc_testing.server_from_dictionary`) - in the same way we can with "true" gRPC Python servers (e.g. `grpc.server`).

### Describe the solution you'd like
Be able to pass an `interceptors` params to a test gRPC server.

### Describe alternatives you've considered
- Replace interceptors with decorators, at least for unit tests -> leads to code complexity
- Not use grpcio-testing and call methods implementing RPCs directly -> Less test coverage (no gRPC level testing)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.