Skip to content

Commit

Permalink
BigQuery: Remove redundant service account key code sample. (#8891)
Browse files Browse the repository at this point in the history
* Remove redundant service account key code sample.

* Remove unused import.
  • Loading branch information
tswast authored Aug 5, 2019
1 parent d156aa9 commit 1b3e822
Showing 1 changed file with 0 additions and 22 deletions.
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

0 comments on commit 1b3e822

Please sign in to comment.