Mock gRPC API – Integration Testing
Here is how you might wanna mock a gRPC API, e.g. I mocked:
- A unary RPC, i.e. the
SayHelloAPI. - A duplex stream (Bidirectional streaming RPC) which I called it
Upload.
How to Start it
cd python/docs/integration-testing/mock-grpc-api.make init.make test.
Fixtures
I am auto loading all fixtures here to make adding new fixtures easier, but keeep in mind that your fixture file name should be like: *_fixture.py.
Fixture Loading and Execution Timing
Fixtures are NOT loaded at the beginning and cached forever. Fixtures in pytest have scope and lifecycle:
functionscope (default): Created/destroyed for each test function.classscope: Created once per test class.modulescope: Created once per test file.sessionscope: Created once per entire test session.