gapic-generator-python icon indicating copy to clipboard operation
gapic-generator-python copied to clipboard

Assertion error in generated unit tests for `x-goog-request-params` header

Open vam-google opened this issue 2 years ago • 3 comments

Affected APIs:

//google/cloud/run/v2/run_py_gapic_test

Failure example:

google/cloud/run/v2/run_py_gapic_srcjar.py/tests/unit/gapic/run_v2/test_revisions.py:1014: AssertionError
___________________________ test_list_services_pager ___________________________

transport_name = 'grpc'

    def test_list_services_pager(transport_name: str = "grpc"):
        client = ServicesClient(
            credentials=ga_credentials.AnonymousCredentials,
            transport=transport_name,
        )
    
        # Mock the actual call within the gRPC stub, and fake the request.
        with mock.patch.object(
                type(client.transport.list_services),
                '__call__') as call:
            # Set the response to a series of pages.
            call.side_effect = (
                service.ListServicesResponse(
                    services=[
                        service.Service(),
                        service.Service(),
                        service.Service(),
                    ],
                    next_page_token='abc',
                ),
                service.ListServicesResponse(
                    services=[],
                    next_page_token='def',
                ),
                service.ListServicesResponse(
                    services=[
                        service.Service(),
                    ],
                    next_page_token='ghi',
                ),
                service.ListServicesResponse(
                    services=[
                        service.Service(),
                        service.Service(),
                    ],
                ),
                RuntimeError,
            )
    
            metadata = ()
            metadata = tuple(metadata) + (
                gapic_v1.routing_header.to_grpc_metadata((
                    ('parent', ''),
                )),
            )
            pager = client.list_services(request={})
    
>           assert pager._metadata == metadata
E           AssertionError: assert () == (('x-goog-req..., 'parent='),)
E             Right contains one more item: ('x-goog-request-params', 'parent=')
E             Use -v to get more diff

google/cloud/run/v2/run_py_gapic_srcjar.py/tests/unit/gapic/run_v2/test_services.py:1246: AssertionError
=========================== short test summary info ============================
FAILED google/cloud/run/v2/run_py_gapic_srcjar.py/tests/unit/gapic/run_v2/test_revisions.py::test_list_revisions_pager
FAILED google/cloud/run/v2/run_py_gapic_srcjar.py/tests/unit/gapic/run_v2/test_services.py::test_list_services_pager
2 failed, 276 passed, 81 warnings in 1.69s
      

vam-google avatar Jul 26 '22 21:07 vam-google

The issue is not reproducible anymore. There were changes in run api itself, probably it got fixed by fixing proto definitions.

vam-google avatar Sep 09 '22 19:09 vam-google

This is still happening if you have a URL parameter in a List call with an int64 type.

SRabbelier avatar Oct 08 '22 00:10 SRabbelier

@SRabbelier please post error details and stacktrace if you have any.

vam-google avatar Oct 14 '22 23:10 vam-google

Closing due to inactivity.

parthea avatar Feb 28 '23 18:02 parthea

Reopening per @SRabbelier's internal request: this still seems to be happening.

@SRabbelier : can you post additional details. @vam-google said this was no longer happening. Where are you reproducing this?

vchudnov-g avatar Feb 28 '23 22:02 vchudnov-g