Пример #1
0
    def test_ga_hook_is_passed_from_private_key(self, build):
        ga_hook = Mock()
        client = from_private_key('account_name',
                                  'private_key',
                                  storage_path='/tmp/foo.dat',
                                  ga_hook=ga_hook)

        self.assertEqual(client._ga_hook, ga_hook)
Пример #2
0
    def test_ga_hook_is_passed_from_private_key(self, build):
        ga_hook = Mock()
        client = from_private_key(
            'account_name', 'private_key',
            storage_path='/tmp/foo.dat',
            ga_hook=ga_hook)

        self.assertEqual(client._ga_hook, ga_hook)
Пример #3
0
def _create_client(credentials):
    if "CLIENT_SECRETS" in credentials:
        return from_secrets_file(
            credentials['CLIENT_SECRETS'],
            storage_path=credentials['STORAGE_PATH']

        )
    else:
        return from_private_key(
            credentials['ACCOUNT_NAME'],
            private_key_path=credentials['PRIVATE_KEY'],
            storage_path=credentials['STORAGE_PATH']
        )
Пример #4
0
def _create_client(credentials):
    if "CLIENT_SECRETS" in credentials:
        return from_secrets_file(
            credentials['CLIENT_SECRETS'],
            storage_path=credentials['STORAGE_PATH']

        )
    else:
        return from_private_key(
            credentials['ACCOUNT_NAME'],
            private_key_path=credentials['PRIVATE_KEY'],
            storage_path=credentials['STORAGE_PATH']
        )
def create_client(credentials):
    if "CLIENT_SECRETS" in credentials:
        return from_secrets_file(
            credentials['CLIENT_SECRETS'],
            storage_path=credentials['STORAGE_PATH'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )
    else:
        return from_private_key(
            credentials['ACCOUNT_NAME'],
            private_key_path=credentials['PRIVATE_KEY'],
            storage_path=credentials['STORAGE_PATH'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )
def create_client(credentials):
    if "CLIENT_SECRETS" in credentials and "STORAGE_PATH" in credentials:
        return from_secrets_file(
            credentials['CLIENT_SECRETS'],
            storage_path=credentials['STORAGE_PATH'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )
    elif "ACCOUNT_NAME" in credentials:
        return from_private_key(
            credentials['ACCOUNT_NAME'],
            private_key_path=credentials['PRIVATE_KEY'],
            storage_path=credentials['STORAGE_PATH'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )
    else:
        return from_credentials_db(
            credentials['CLIENT_SECRETS']['installed'],
            credentials['OAUTH2_CREDENTIALS'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )
Пример #7
0
 def test_service_account_created(self, build):
     client = from_private_key(
         "account_name", "private_key",
         storage_path="/tmp/foo.dat")
     build.assert_called_with(ANY, ANY)
     self.assertTrue(isinstance(client, Client))
Пример #8
0
 def test_service_account_created(self, build):
     client = from_private_key("account_name",
                               "private_key",
                               storage_path="/tmp/foo.dat")
     build.assert_called_with(ANY, ANY, None)
     self.assertTrue(isinstance(client, Client))