Skip to content
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

Generated tests for showcase fail with compliance.proto #1993

Open
parthea opened this issue Mar 21, 2024 · 1 comment
Open

Generated tests for showcase fail with compliance.proto #1993

parthea opened this issue Mar 21, 2024 · 1 comment
Assignees
Labels
type: cleanup An internal cleanup or hygiene concern.

Comments

@parthea
Copy link
Contributor

parthea commented Mar 21, 2024

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')]]
@parthea parthea added the type: cleanup An internal cleanup or hygiene concern. label Mar 21, 2024
@parthea
Copy link
Contributor Author

parthea commented Mar 21, 2024

This is the same issue as #1444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

No branches or pull requests

2 participants