Skip to content

Generated tests for showcase fail with compliance.proto #1993

@parthea

Description

@parthea

compliance.proto is not used in showcase testing.

cmd_tup = (
"python",
"-m",
"grpc_tools.protoc",
f"--experimental_allow_proto3_optional",
f"--descriptor_set_in={tmp_dir}{path.sep}showcase.desc",
opts,
f"--python_gapic_out={tmp_dir}",
f"google/showcase/v1beta1/echo.proto",
f"google/showcase/v1beta1/identity.proto",
f"google/showcase/v1beta1/messaging.proto",
)

If compliance.proto is added, 2 generated tests fail. See the stack trace below and PR #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')]]

Metadata

Metadata

Assignees

Labels

type: cleanupAn internal cleanup or hygiene concern.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions