コード例 #1
0
def test_credentials_transport_error():
    # It is an error to provide credentials and a transport instance.
    transport = transports.LicenseCodesRestTransport(
        credentials=ga_credentials.AnonymousCredentials(), )
    with pytest.raises(ValueError):
        client = LicenseCodesClient(
            credentials=ga_credentials.AnonymousCredentials(),
            transport=transport,
        )

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

    # It is an error to provide scopes and a transport instance.
    transport = transports.LicenseCodesRestTransport(
        credentials=ga_credentials.AnonymousCredentials(), )
    with pytest.raises(ValueError):
        client = LicenseCodesClient(
            client_options={"scopes": ["1", "2"]},
            transport=transport,
        )
コード例 #2
0
def test_transport_instance():
    # A client may be instantiated with a custom transport instance.
    transport = transports.LicenseCodesRestTransport(
        credentials=ga_credentials.AnonymousCredentials(),
    )
    client = LicenseCodesClient(transport=transport)
    assert client.transport is transport
コード例 #3
0
def test_license_codes_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.LicenseCodesRestTransport(
            credentials=cred, client_cert_source_for_mtls=client_cert_source_callback
        )
        mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback)
コード例 #4
0
def test_get_rest_unset_required_fields():
    transport = transports.LicenseCodesRestTransport(
        credentials=ga_credentials.AnonymousCredentials)

    unset_fields = transport.get._get_unset_required_fields({})
    assert set(unset_fields) == (set(()) & set((
        "licenseCode",
        "project",
    )))
コード例 #5
0
def test_test_iam_permissions_rest_unset_required_fields():
    transport = transports.LicenseCodesRestTransport(
        credentials=ga_credentials.AnonymousCredentials)

    unset_fields = transport.test_iam_permissions._get_unset_required_fields(
        {})
    assert set(unset_fields) == (set(()) & set((
        "project",
        "resource",
        "testPermissionsRequestResource",
    )))