-
Notifications
You must be signed in to change notification settings - Fork 78
fix: updates tests for ListValue response fields #2532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: updates tests for ListValue response fields #2532
Conversation
Relax assertion checks in generated pager tests to allow `Sequence` for `struct_pb2.ListValue` and `Mapping` for `struct_pb2.Struct`, as `proto-plus` converts these WKTs to native Python types. Also handles `struct_pb2.Value` mapping to `Any`. This fixes an `AssertionError` where tests expected `struct_pb2.ListValue` instances but received list-like objects (e.g. `RepeatedComposite` or `list`).
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This reverts commit dbc1a97.
chalmerlowe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Switching from
struct_pb2.ListValuetocollections.abc.Sequence(andStructtoMapping) to fix test failures identified in #2534 and make the generated tests more resilient.Why the test is failing
When we compare gRPC and HTTP responses:
struct_pb2.ListValue).requestsoraiohttp) usually returns native Python types (e.g., a standardlistordict) after the JSON body is decoded.Because a standard Python
listis not an instance ofstruct_pb2.ListValue, your checkisinstance(i, struct_pb2.ListValue)returnsFalsefor the HTTP response, even if the data inside is identical.The "Primitive" Types (ABCs)
The Protocol Buffer implementation for Python registers
StructandListValuewith Python’s Abstract Base Classes (ABCs). This means they are designed to "masquerade" as native collections.Structcollections.abc.Mappingcollections.abc.MutableMappingListValuecollections.abc.Sequencecollections.abc.MutableSequenceValueUpdated Check
This aligns the tests with
proto-plusbehavior regarding Well-Known Types.PR created automatically by Jules for task 9413892356993396464 started by @chalmerlowe