fix(pubsub): handle internal metadata changes in google-api-core - #18037
Open
chalmerlowe wants to merge 1 commit into
Open
fix(pubsub): handle internal metadata changes in google-api-core#18037chalmerlowe wants to merge 1 commit into
chalmerlowe wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the unit tests for both the publisher and subscriber clients to handle internal changes in the google-api-core library's _GapicCallable. Specifically, it safely retrieves metadata from wrapped methods by falling back to _default_metadata if _metadata is not present. Additionally, some minor import cleanups were performed. There are no review comments, and I have no feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
test_init_default_client_infotests ingoogle-cloud-pubsub(for both Publisher and Subscriber) were brittle because they peeked into the private internal attributes of_GapicCallable(fromgoogle-api-core) to verify metadata.Recent refactoring in
google-api-corerenamed/removed the_metadataattribute, causing these tests to fail withAttributeError: '_GapicCallable' object has no attribute '_metadata'.Solution
Refactored
test_init_default_client_infointest_publisher_client.pyandtest_subscriber_client.pyto use mocking instead of peeking into internal state.unittest.mock.patchto intercept calls togoogle.api_core.gapic_v1.method.wrap_method.wrap_methodis called with the expectedclient_infoobject.client_infocontains the correct library version string (e.g.,gccl/x.y.z).Why this is important
google-api-core).wrap_method) remains stable.google-cloud-bigquery-storage).Blocks: #17642