Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the test interceptor architecture by deprecating the enable_interceptors_in_tests parameter and removing the test-only TestDatabase class from the production package. It introduces a dedicated tests._interceptors module with gRPC client interceptors and channel attachment helpers, updating the test suite accordingly. The review feedback recommends normalizing gRPC method names (which can be str or bytes) to strings in both MethodCountInterceptor and MethodAbortInterceptor to prevent lookup and comparison failures during testing.
a230d45 to
5d0db24
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request deprecates the enable_interceptors_in_tests parameter in Instance.database and removes the test-only TestDatabase class and interceptors from the production package, refactoring them into a test-only module (tests/_interceptors.py). The mock server, system, and unit tests have been updated to use the new interceptor attachment helpers. The review feedback recommends adding explicit cleanup steps or assigning databases to self._database in several test cases to prevent gRPC channel resource leaks.
Remove internal test infrastructure (mock servers, generated test gRPC stubs, test database subclasses, and test interceptors) from the shipped Spanner package so test plumbing is no longer distributed to production users. - Keep `enable_interceptors_in_tests` as a deprecated no-op on database creation (sync and async), emitting a deprecation warning when enabled so callers have a grace period before removal. - Move the mock server and interceptor helpers into the test suite, attaching test interceptors directly to standard database channels during test setup and enforcing request-ID headers on the mock server across both sync and async suites. - Migrate all existing mock server, system, and unit tests to standard databases, ensure test databases and gRPC transports are closed on teardown, and add unit and mock server tests covering the deprecation warning and moved test helpers.
5d0db24 to
f6638a0
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request deprecates the enable_interceptors_in_tests parameter and removes the test-only TestDatabase class, replacing them with a new test-only helper module tests/_interceptors.py that provides thread-safe sync and async gRPC client interceptors and channel attachment helpers. Additionally, it updates mock server, system, and unit tests to use these new helpers and adds request-ID header validation to the mock Spanner server. The review feedback highlights a compatibility issue with Python versions prior to 3.10 due to the runtime use of the PEP 604 union operator | in isinstance checks, and suggests using getattr to safely access private attributes on mock or external objects to prevent potential AttributeErrors.
Remove internal test infrastructure (mock servers, generated test gRPC stubs, test database subclasses, and test interceptors) from the shipped Spanner package so test plumbing is no longer distributed to production users.
enable_interceptors_in_testsas a deprecated no-op on database creation (sync and async), emitting a deprecation warning when enabled so callers have a grace period before removal.