Example #1
0
def test_license_notification_service_base_transport_with_adc():
    # Test the default credentials are used if credentials and credentials_file are None.
    with mock.patch.object(
            google.auth, 'default', autospec=True
    ) as adc, mock.patch(
            'ccc.hosted.marketplace_v2.services.license_notification_service.transports.LicenseNotificationServiceTransport._prep_wrapped_messages'
    ) as Transport:
        Transport.return_value = None
        adc.return_value = (ga_credentials.AnonymousCredentials(), None)
        transport = transports.LicenseNotificationServiceTransport()
        adc.assert_called_once()
Example #2
0
def test_license_notification_service_base_transport():
    # Instantiate the base transport.
    with mock.patch(
            'ccc.hosted.marketplace_v2.services.license_notification_service.transports.LicenseNotificationServiceTransport.__init__'
    ) as Transport:
        Transport.return_value = None
        transport = transports.LicenseNotificationServiceTransport(
            credentials=ga_credentials.AnonymousCredentials(), )

    # Every method on the transport should just blindly
    # raise NotImplementedError.
    methods = ('list', )
    for method in methods:
        with pytest.raises(NotImplementedError):
            getattr(transport, method)(request=object())
Example #3
0
def test_license_notification_service_base_transport_with_credentials_file_old_google_auth(
):
    # Instantiate the base transport with a credentials file
    with mock.patch.object(
            google.auth, 'load_credentials_from_file', autospec=True
    ) as load_creds, mock.patch(
            'ccc.hosted.marketplace_v2.services.license_notification_service.transports.LicenseNotificationServiceTransport._prep_wrapped_messages'
    ) as Transport:
        Transport.return_value = None
        load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
        transport = transports.LicenseNotificationServiceTransport(
            credentials_file="credentials.json",
            quota_project_id="octopus",
        )
        load_creds.assert_called_once_with(
            "credentials.json",
            scopes=(
                'https://www.googleapis.com/auth/appsmarketplace.license', ),
            quota_project_id="octopus",
        )
Example #4
0
def test_license_notification_service_base_transport_error():
    # Passing both a credentials object and credentials_file should raise an error
    with pytest.raises(core_exceptions.DuplicateCredentialArgs):
        transport = transports.LicenseNotificationServiceTransport(
            credentials=ga_credentials.AnonymousCredentials(),
            credentials_file="credentials.json")