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

Generated tests for showcase fail with `compliance.proto`

Open parthea opened this issue 1 year ago • 1 comments

compliance.proto is not used in showcase testing.

https://github.com/googleapis/gapic-generator-python/blob/24a23a1ab885246e447c0010b2e5602209dfbb8d/noxfile.py#L242-L253

If compliance.proto is added, 2 generated tests fail. See the stack trace below and PR https://github.com/googleapis/gapic-generator-python/pull/1992

https://github.com/googleapis/gapic-generator-python/actions/runs/8381341747/job/22952651655?pr=1992

[__________________ test_repeat_data_simple_path_field_headers __________________
[gw0] linux -- Python 3.8.18 /home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_mixins-3-8/bin/python

    def test_repeat_data_simple_path_field_headers():
        client = ComplianceClient(
            credentials=ga_credentials.AnonymousCredentials(),
        )
    
        # Any value that is part of the HTTP/1.1 URI should be sent as
        # a field header. Set these to a non-empty value.
        request = compliance.RepeatRequest()
    
        request.info.f_string = 'f_string_value'
        request.info.f_int32 = 629
        request.info.f_double = 0.8320000000000001
        request.info.f_bool = True
        request.info.f_kingdom = compliance.ComplianceData.LifeKingdom.ARCHAEBACTERIA
    
        # Mock the actual call within the gRPC stub, and fake the request.
        with mock.patch.object(
                type(client.transport.repeat_data_simple_path),
                '__call__') as call:
            call.return_value = compliance.RepeatResponse()
            client.repeat_data_simple_path(request)
    
            # Establish that the underlying gRPC stub method was called.
            assert len(call.mock_calls) == 1
            _, args, _ = call.mock_calls[0]
            assert args[0] == request
    
        # Establish that the field header was sent.
        _, _, kw = call.mock_calls[0]
>       assert (
            'x-goog-request-params',
            'info.f_string=f_string_value&info.f_int32=629&info.f_double=0.8320000000000001&info.f_bool=True&info.f_kingdom=compliance.ComplianceData.LifeKingdom.ARCHAEBACTERIA',
        ) in kw['metadata']
E       AssertionError: assert ('x-goog-request-params', 'info.f_string=f_string_value&info.f_int32=629&info.f_double=0.8320000000000001&info.f_bool=True&info.f_kingdom=compliance.ComplianceData.LifeKingdom.ARCHAEBACTERIA') in [('x-goog-request-params', 'info.f_string=f_string_value&info.f_int32=629&info.f_double=0.8320000000000001&info.f_bool...o.f_kingdom=LifeKingdom.ARCHAEBACTERIA'), ('x-goog-api-client', 'gl-python/3.8.18 grpc/1.62.1 gax/2.18.0 gapic/0.0.0')]

tests/unit/gapic/showcase_v1beta1/test_compliance.py:1140: AssertionError
_______________ test_repeat_data_simple_path_field_headers_async _______________
[gw0] linux -- Python 3.8.18 /home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_mixins-3-8/bin/python

    @pytest.mark.asyncio
    async def test_repeat_data_simple_path_field_headers_async():
        client = ComplianceAsyncClient(
            credentials=ga_credentials.AnonymousCredentials(),
        )
    
        # Any value that is part of the HTTP/1.1 URI should be sent as
        # a field header. Set these to a non-empty value.
        request = compliance.RepeatRequest()
    
        request.info.f_string = 'f_string_value'
        request.info.f_int32 = 629
        request.info.f_double = 0.8320000000000001
        request.info.f_bool = True
        request.info.f_kingdom = compliance.ComplianceData.LifeKingdom.ARCHAEBACTERIA
    
        # Mock the actual call within the gRPC stub, and fake the request.
        with mock.patch.object(
                type(client.transport.repeat_data_simple_path),
                '__call__') as call:
            call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(compliance.RepeatResponse())
            await client.repeat_data_simple_path(request)
    
            # Establish that the underlying gRPC stub method was called.
            assert len(call.mock_calls)
            _, args, _ = call.mock_calls[0]
            assert args[0] == request
    
        # Establish that the field header was sent.
        _, _, kw = call.mock_calls[0]
>       assert (
            'x-goog-request-params',
            'info.f_string=f_string_value&info.f_int32=629&info.f_double=0..8320000000000001&info.f_bool=True&info.f_kingdom=compliance.ComplianceData.LifeKingdom.ARCHAEBACTERIA',
        ) in kw['metadata']
E       AssertionError: assert ('x-goog-request-params', 'info.f_string=f_string_value&info.f_int32=629&info.f_double=0.8320000000000001&info.f_bool=True&info.f_kingdom=compliance.ComplianceData.LifeKingdom.ARCHAEBACTERIA') in [('x-goog-request-params', 'info.f_string=f_string_value&info.f_int32=629&info.f_double=0.8320000000000001&info.f_bool...o.f_kingdom=LifeKingdom.ARCHAEBACTERIA'), ('x-goog-api-client', 'gl-python/3.8.18 grpc/1.62.1 gax/2.18.0 gapic/0.0.0')]]

parthea avatar Mar 21 '24 20:03 parthea

This is the same issue as https://github.com/googleapis/gapic-generator-python/issues/1444

parthea avatar Mar 21 '24 21:03 parthea