Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigQuery: Remove redundant service account key code sample. #8891

Merged
merged 3 commits into from
Aug 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions bigquery/docs/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import os
import time

import mock
import pytest
import six

Expand Down Expand Up @@ -126,27 +125,6 @@ def test_create_client_default_credentials():
assert client is not None


def test_create_client_json_credentials():
"""Create a BigQuery client with Application Default Credentials"""
with open(os.environ["GOOGLE_APPLICATION_CREDENTIALS"]) as creds_file:
creds_file_data = creds_file.read()

open_mock = mock.mock_open(read_data=creds_file_data)

with mock.patch("io.open", open_mock):
# [START bigquery_client_json_credentials]
from google.cloud import bigquery

# Explicitly use service account credentials by specifying the private
# key file. All clients in google-cloud-python have this helper.
client = bigquery.Client.from_service_account_json(
"path/to/service_account.json"
)
# [END bigquery_client_json_credentials]

assert client is not None


def test_list_datasets_by_label(client, to_delete):
dataset_id = "list_datasets_by_label_{}".format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
Expand Down