Skip to content

Update assert test to correct for mismatch between grpc and http return types #2534

@chalmerlowe

Description

@chalmerlowe

While running tests (via gbazelisk test //google3/google/cloud/...) an error came up:

The error appears to be related to a mismatch in response type for GRPC and HTTP.

            assert len(responses) == 6
>           assert all(isinstance(i, struct_pb2.ListValue)
                    for i in responses)
E           assert False
E            +  where False = all(<generator object test_read_report_async_pager.<locals>.<genexpr> at 0x7f6adfab8660>)

google/cloud/appoptimize/v1alpha/appoptimize_py_gapic_srcjar.py/tests/unit/gapic/appoptimize_v1alpha/test_app_optimize.py:2890: AssertionError
_________________________ test_read_report_rest_pager __________________________

Specifically, when you compare gRPC and HTTP responses:

  • gRPC typically returns the actual Protobuf Message object (e.g., an instance of struct_pb2.ListValue).
  • HTTP/REST (using libraries like requests or aiohttp) usually returns native Python types (e.g., a standard list or dict) after the JSON body is decoded.

Modify the test to compare these two items via an isinstance check against Sequence (which is a superclass of both ListValue and list).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions