This directory contains integration tests for the BaseApiClient and its utility functions, including authentication and signing interceptors, and the GrpcStreamBroadcaster.
demo.proto- Minimal gRPC service definition with unary and streaming methodsdemo_pb2.py- Generated protobuf message classesdemo_pb2_grpc.py- Generated gRPC stub classes
test_server.py- Test gRPC server implementation using grpc.aiotest_client.py- Test client subclassing BaseApiClient with proper stub typing
test_integration.py- Full integration tests using real gRPC componentstest_mock_integration.py- Mock-based integration tests for environments without gRPC dependenciestest_simple_validation.py- Simple validation test to verify test infrastructuretest_runner.py- Standalone test runner (work in progress)
The integration tests cover:
- Unary RPC calls using
call_stub_method()utility function - Server-streaming RPC calls with proper async iteration
- GrpcStreamBroadcaster functionality:
- Single consumer scenarios
- Multiple consumer scenarios
- Event handling (StreamStarted, StreamRetrying, StreamFatalError)
- Authentication interceptors (API key)
- Signing interceptors (HMAC signing)
- Timeout handling throughout all operations
If you have grpcio and pytest installed:
python -m pytest tests/integration/test_integration.py -vFor environments without gRPC dependencies:
python -m pytest tests/integration/test_mock_integration.py -vTo verify the test infrastructure is set up correctly:
python tests/integration/test_simple_validation.pyThe test service includes:
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
rpc StreamHellos (HelloRequest) returns (stream HelloReply);
}This provides both unary and server-streaming RPC patterns for comprehensive testing.
- BaseApiClient subclassing with proper stub typing
- Authentication and signing interceptor integration
- Stream broadcasting to multiple consumers
- Error handling and retries in streaming scenarios
- Timeout management across all operations
- Real client-server communication patterns
These tests ensure that the core abstractions and security features work together as intended in a minimal and reproducible environment.