Skip to content

python: unit test is failing with auth mock objects #6967

Description

@suztomo

unittest / unit (3.13) (pull_request) is failing.

...
        if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
            for config_data, expected_cert_source in test_cases:
                env = os.environ.copy()
                env.pop("GOOGLE_API_USE_CLIENT_CERTIFICATE", None)
                with mock.patch.dict(os.environ, env, clear=True):
                    config_filename = "mock_certificate_config.json"
                    config_file_content = json.dumps(config_data)
                    m = mock.mock_open(read_data=config_file_content)
                    with mock.patch("builtins.open", m):
                        with mock.patch.dict(
                            os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
                        ):
                            mock_api_endpoint = "foo"
                            options = client_options.ClientOptions(
                                client_cert_source=mock_client_cert_source,
                                api_endpoint=mock_api_endpoint,
                            )
                            api_endpoint, cert_source = (
                                client_class.get_mtls_endpoint_and_cert_source(options)
                            )
                            assert api_endpoint == mock_api_endpoint
>                           assert cert_source is expected_cert_source
E                           AssertionError: assert None is <Mock id='140028694900960'>

tests/unit/gapic/agentidentitycredentials_v1beta/test_auth_provider_credentials_service.py:1080: AssertionError
_ test_auth_provider_credentials_service_client_get_mtls_endpoint_and_cert_source[AuthProviderCredentialsServiceAsyncClient] _

The generator template change in gapic-generator was merged in googleapis/google-cloud-python#17807.

How to reproduce

The sequence of the commands in "Python > Update librarian version" at http://doc/1moP7zq3Qy7xqjdKSpTJhHbhpX7dSG9Wo38f9nlEpcLQ/edit?resourcekey=0-p1YPSwMTMGFYRgr4jegcOw&tab=t.0#heading=h.ug6i6d2phk3d reproduces the issue where V is 0.30.0 and google-cloud-node revision is ef89c2c49284b9bb3e57173228e5a0e5c14726f8 "chore(librarian): fix post processing script for logging (#17836)".

Metadata

Metadata

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