Skip to content

Remove OAuth cache discovery from google client library. (#1) #146

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

Merged
merged 1 commit into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,13 @@ def _get_bq_service(credentials=None, service_url=None):
assert credentials, 'Must provide ServiceAccountCredentials'

http = credentials.authorize(Http())
service = build('bigquery', 'v2', http=http,
discoveryServiceUrl=service_url)
service = build(
'bigquery',
'v2',
http=http,
discoveryServiceUrl=service_url,
cache_discovery=False
)

return service

Expand Down
45 changes: 35 additions & 10 deletions bigquery/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ def test_initialize_readonly(self, mock_build, mock_return_cred):
scopes=BIGQUERY_SCOPE_READ_ONLY)
self.assertTrue(
mock_cred.from_p12_keyfile_buffer.return_value.authorize.called)
mock_build.assert_called_once_with('bigquery', 'v2', http=mock_http,
discoveryServiceUrl=mock_service_url)
mock_build.assert_called_once_with(
'bigquery',
'v2',
http=mock_http,
discoveryServiceUrl=mock_service_url,
cache_discovery=False
)
self.assertEquals(mock_bq, bq_client.bigquery)
self.assertEquals(project_id, bq_client.project_id)

Expand Down Expand Up @@ -101,8 +106,13 @@ def test_initialize_read_write(self, mock_build, mock_return_cred):
service_account, mock.ANY, scopes=BIGQUERY_SCOPE)
self.assertTrue(
mock_cred.from_p12_keyfile_buffer.return_value.authorize.called)
mock_build.assert_called_once_with('bigquery', 'v2', http=mock_http,
discoveryServiceUrl=mock_service_url)
mock_build.assert_called_once_with(
'bigquery',
'v2',
http=mock_http,
discoveryServiceUrl=mock_service_url,
cache_discovery=False
)
self.assertEquals(mock_bq, bq_client.bigquery)
self.assertEquals(project_id, bq_client.project_id)

Expand Down Expand Up @@ -136,8 +146,13 @@ def test_initialize_key_file(self, mock_build, mock_return_cred):
scopes=BIGQUERY_SCOPE)
self.assertTrue(
mock_cred.from_p12_keyfile.return_value.authorize.called)
mock_build.assert_called_once_with('bigquery', 'v2', http=mock_http,
discoveryServiceUrl=mock_service_url)
mock_build.assert_called_once_with(
'bigquery',
'v2',
http=mock_http,
discoveryServiceUrl=mock_service_url,
cache_discovery=False
)
self.assertEquals(mock_bq, bq_client.bigquery)
self.assertEquals(project_id, bq_client.project_id)

Expand Down Expand Up @@ -172,8 +187,13 @@ def test_initialize_json_key_file(self, mock_open, mock_build, mock_return_cred)
scopes=BIGQUERY_SCOPE)
self.assertTrue(
mock_cred.from_json_keyfile_dict.return_value.authorize.called)
mock_build.assert_called_once_with('bigquery', 'v2', http=mock_http,
discoveryServiceUrl=mock_service_url)
mock_build.assert_called_once_with(
'bigquery',
'v2',
http=mock_http,
discoveryServiceUrl=mock_service_url,
cache_discovery=False
)
self.assertEquals(mock_bq, bq_client.bigquery)
self.assertEquals(project_id, bq_client.project_id)

Expand Down Expand Up @@ -208,8 +228,13 @@ def test_initialize_json_key_file_without_project_id(self, mock_open, mock_build
scopes=BIGQUERY_SCOPE)
self.assertTrue(
mock_cred.from_json_keyfile_dict.return_value.authorize.called)
mock_build.assert_called_once_with('bigquery', 'v2', http=mock_http,
discoveryServiceUrl=mock_service_url)
mock_build.assert_called_once_with(
'bigquery',
'v2',
http=mock_http,
discoveryServiceUrl=mock_service_url,
cache_discovery=False
)
self.assertEquals(mock_bq, bq_client.bigquery)
self.assertEquals(json_key['project_id'], bq_client.project_id)

Expand Down