예제 #1
0
def test_credentials_transport_error():
    # It is an error to provide credentials and a transport instance.
    transport = transports.RegionNotificationEndpointsRestTransport(
        credentials=ga_credentials.AnonymousCredentials(), )
    with pytest.raises(ValueError):
        client = RegionNotificationEndpointsClient(
            credentials=ga_credentials.AnonymousCredentials(),
            transport=transport,
        )

    # It is an error to provide a credentials file and a transport instance.
    transport = transports.RegionNotificationEndpointsRestTransport(
        credentials=ga_credentials.AnonymousCredentials(), )
    with pytest.raises(ValueError):
        client = RegionNotificationEndpointsClient(
            client_options={"credentials_file": "credentials.json"},
            transport=transport,
        )

    # It is an error to provide scopes and a transport instance.
    transport = transports.RegionNotificationEndpointsRestTransport(
        credentials=ga_credentials.AnonymousCredentials(), )
    with pytest.raises(ValueError):
        client = RegionNotificationEndpointsClient(
            client_options={"scopes": ["1", "2"]},
            transport=transport,
        )
예제 #2
0
def test_region_notification_endpoints_http_transport_client_cert_source_for_mtls(
):
    cred = ga_credentials.AnonymousCredentials()
    with mock.patch(
            "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"
    ) as mock_configure_mtls_channel:
        transports.RegionNotificationEndpointsRestTransport(
            credentials=cred,
            client_cert_source_for_mtls=client_cert_source_callback)
        mock_configure_mtls_channel.assert_called_once_with(
            client_cert_source_callback)
예제 #3
0
def test_transport_instance():
    # A client may be instantiated with a custom transport instance.
    transport = transports.RegionNotificationEndpointsRestTransport(
        credentials=ga_credentials.AnonymousCredentials(), )
    client = RegionNotificationEndpointsClient(transport=transport)
    assert client.transport is transport