def test_valid_credentials(self): creds = httplib2_utils.load_service_account_credentials( 'valid_creds.json', service_accounts_creds_root=DATA_DIR) self.assertIsInstance(creds, dict) self.assertIn('type', creds) self.assertIn('client_email', creds) self.assertIn('private_key', creds)
def test_file_not_found(self): with self.assertRaises(IOError): httplib2_utils.load_service_account_credentials( 'this_file_should_not_exist.json', service_accounts_creds_root=DATA_DIR)
def test_malformed(self): with self.assertRaises(httplib2_utils.AuthError): httplib2_utils.load_service_account_credentials( 'creds_malformed.json', service_accounts_creds_root=DATA_DIR)
def test_missing_private_key(self): with self.assertRaises(httplib2_utils.AuthError): httplib2_utils.load_service_account_credentials( 'creds_missing_private_key.json', service_accounts_creds_root=DATA_DIR)
def test_missing_client_email(self): with self.assertRaises(infra_libs.AuthError): httplib2_utils.load_service_account_credentials( 'creds_missing_client_email.json', service_accounts_creds_root=DATA_DIR)
def test_wrong_type(self): with self.assertRaises(infra_libs.AuthError): httplib2_utils.load_service_account_credentials( 'creds_wrong_type.json', service_accounts_creds_root=DATA_DIR)