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

Dlp: Regeneration and hand edits #3850

Merged
merged 216 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
216 commits
Select commit Hold shift + click to select a range
9c48ace
Fix a couple of video intelligence issues. (#3447)
lukesneeringer May 23, 2017
c82cd6b
corrected package name (#3452)
merla18 May 25, 2017
5e86158
Show how to create credentials object (#3454)
ricardolui May 30, 2017
7e73e78
Add 'Query.num_dml_affected_rows' property. (#3460)
tseaver May 31, 2017
a0f079f
Re-organize the documentation structure in preparation to split docs …
May 31, 2017
85fd45a
Someone changed auth link and broke this link (#3464)
ricardolui Jun 1, 2017
72e6e52
Vision semi-GAPIC (#3373)
lukesneeringer Jun 2, 2017
38bdb44
Reloading BigQuery table in system test before fetching data. (#3468)
dhermes Jun 2, 2017
af1fd7e
Send trace context with logs from web applications (#3448)
liyanhui1228 Jun 2, 2017
b0abcb2
Add Part Of Speech missing data to Token (#3457)
dvaldivia Jun 5, 2017
45084cf
Revert "Fix "broken" docs build. (#3422)" (#3439)
dhermes Jun 5, 2017
92a20c6
Using part of speech "tag" in system test. (#3471)
dhermes Jun 5, 2017
a55010f
Adding optional switch to capture project ID in from_service_account_…
dhermes Jun 6, 2017
bdb7e0a
Reverse direction of dependencies when determining target packages. (…
dhermes Jun 6, 2017
9b2668c
Updating Bigtable Client docstring to reflect new credentials. (#3477)
dhermes Jun 6, 2017
179997e
Add 'Bucket.labels' property. (#3478)
tseaver Jun 6, 2017
0031840
Remove external GAPIC dependency for Vision.
Jun 7, 2017
dfcbbfb
Fix deps (#3480)
lukesneeringer Jun 7, 2017
b24b315
Expose that settable properties are so. (#3472)
tseaver Jun 7, 2017
8dacdb9
Remap new Gax conflict error code (#3443)
tseaver Jun 7, 2017
b67570f
Remove a reference to language API as beta. (#3487)
lukesneeringer Jun 8, 2017
8682e53
Adding datastore Key.(to|from)_legacy_urlsafe. (#3491)
dhermes Jun 8, 2017
5697b3a
Make 'QueryResponse.fetch_data' return an iterator. (#3484)
tseaver Jun 9, 2017
62598f4
Add 'Bucket.requester_pays' property. (#3488)
tseaver Jun 9, 2017
f29abec
Use alabaster theme (#3496)
Jun 13, 2017
60832b8
Add '{Bucket,Blob}.user_project' properties. (#3490)
tseaver Jun 13, 2017
04c07a5
Pass 'user_project' if set for Bucket API requests (#3492)
tseaver Jun 13, 2017
313b1fa
Pass 'user_project' if set for Blob API requests (#3495)
tseaver Jun 13, 2017
f14bde3
Pass 'user_project' if set for BucketACL/BlobACL API requests (#3499)
tseaver Jun 13, 2017
7e3fae0
Add sentence about row ordering (#3504)
garye Jun 19, 2017
6618165
Allow bulk update of records via 'MutateRows' API (#3401)
CuriousDima Jun 19, 2017
013949f
Fix broken link in the client Google Auth credentials help text (#3517)
parthea Jun 21, 2017
46ced00
Add back pylint as info-only for core (#3515)
Jun 22, 2017
27dcf5a
BigQuery _EnumProperty ValueError messages are not displayed properly…
smasue Jun 23, 2017
cbf073b
Re-enable pylint in info-only mode for all packages (#3519)
Jun 23, 2017
dbdc6a6
Pass 'user_project' if set for blob downloads w/ 'mediaLink' set (#3500)
tseaver Jun 26, 2017
89cfbc2
Back out support for 'requester pays' buckets. (#3538)
tseaver Jun 26, 2017
1d156e3
Prep core-0.25.0 release. (#3526)
tseaver Jun 26, 2017
25b987c
Prep datastore-1.1.0 release. (#3527)
tseaver Jun 26, 2017
67fad20
Prep logging-1.1.0 release. (#3528)
tseaver Jun 26, 2017
fc08ab0
Prep storage-1.2.0 release. (#3540)
tseaver Jun 26, 2017
d93921d
Prep bigquery-0.25.0 release. (#3530)
tseaver Jun 26, 2017
89ce0a6
Prep pubsub-0.26.0 release. (#3532)
tseaver Jun 26, 2017
c448403
Prep bigtable-0.25.0 release. (#3534)
tseaver Jun 26, 2017
cc4e685
Prep language-0.25.0 release. (#3535)
tseaver Jun 26, 2017
273b24f
Prep spanner-0.25.0 release. (#3536)
tseaver Jun 26, 2017
a42347a
Prep dns-0.25.0 release. (#3541)
tseaver Jun 26, 2017
92c468d
Prep monitoring-0.25.0 release. (#3543)
tseaver Jun 26, 2017
25c98d9
Prep resource-manager-0.25.0 release. (#3544)
tseaver Jun 26, 2017
0ac5a24
Prep runtimeconfig-0.25.0 release. (#3545)
tseaver Jun 26, 2017
e70423b
Prep speech-0.26.0 release. (#3546)
tseaver Jun 26, 2017
04ff662
Prep translate-0.25.0 release. (#3547)
tseaver Jun 26, 2017
9238a26
Prep error-reporting-0.25.0 release. (#3542)
tseaver Jun 26, 2017
f0bf9df
Prep vision-0.25.0 release. (#3537)
tseaver Jun 26, 2017
214aba6
Prep umbrella 0.26.0 release. (#3549)
tseaver Jun 26, 2017
14251d9
BQ: cleanup flake8 errors in tests (#3551)
tswast Jun 27, 2017
6ab3e01
Fix inclusion of tests in manifest.in (#3552)
Jun 27, 2017
8ab1afe
Add the ability to specify AnnotateImageRequest items in single-featu…
lukesneeringer Jun 27, 2017
eb03366
Strip base64 padding characters from urlsafe in Datastore's (to|from)…
Jun 28, 2017
39feb3e
Making all LICENSE headers "uniform". (#3563)
dhermes Jun 28, 2017
9068466
Fixes spelling typos (#3566)
rtkaleta Jun 29, 2017
3588f51
Removing google-cloud-core dependency in test_utils package. (#3550)
dhermes Jun 29, 2017
b9cb6d1
Skipping system tests when credentials env. var is unset. (#3475)
dhermes Jun 29, 2017
b22b02c
Remove `apt-get install openssl` from CircleCI config. (#3567)
dhermes Jun 29, 2017
2d81f88
DOC: developers.google.com -> cloud.google.com (#3569)
tswast Jun 29, 2017
2a4511c
Correct API spelling: 'speechContext' -> 'speechContexts'. (#3570)
Jun 30, 2017
14ff1f5
Update doc reference for setting up a service account (#3578)
SeanBE Jul 5, 2017
f621d17
Update 'QueryResponse.fetch_data' docstring to match changes from #34…
tseaver Jul 5, 2017
bc7b0fd
Shorten nox virtualenv names to avoid hashing. (#3585)
tseaver Jul 6, 2017
7fa089c
Add support for creating a view with 'useLegacySql = False' (#3514)
richkadel Jul 6, 2017
358a448
Add support for logging the trace-id in webapp2 apps. (#3593)
csilvers Jul 10, 2017
f69d704
Fixing "long line" lint violation in BigQuery unit tests. (#3596)
dhermes Jul 10, 2017
da3a7bb
Updating author_email in all setup.py. (#3598)
dhermes Jul 11, 2017
569e739
Patch in the version updates made when fixing #3579. (#3591)
dhermes Jul 11, 2017
68720f6
Implementation of DB-API for BigQuery. (#2921)
tswast Jul 12, 2017
66a9258
Spanner p0 system tests (batch #2) (#3604)
tseaver Jul 12, 2017
401bf40
Speech GAPIC to master (#3607)
lukesneeringer Jul 14, 2017
408f357
fix big query documentation broken link (#3611)
davidraleigh Jul 16, 2017
fe9b6cf
Fixing merge conflict in `setup.py` for Speech. (#3609)
dhermes Jul 17, 2017
67f4ba4
RPC retries (second PR) (#3324)
calpeyser Jul 17, 2017
46f519a
Using `CopyFrom` to set protobuf message fields (instead of `MergeFro…
dhermes Jul 17, 2017
59fd1e4
Add a __hash__ implementation to SchemaField (#3601)
azymnis Jul 17, 2017
df4b8eb
Add bigquery jobid to table (#3605)
evaogbe Jul 17, 2017
9c06b35
Add base future package to google.cloud (#3616)
Jul 17, 2017
ce3046e
Fix a typo in BigQuery usage documentation (#3621)
Maerig Jul 18, 2017
d07365f
Using assertEqual instead of assertEquals. (#3619)
dhermes Jul 18, 2017
86c77ef
Add `is_nullable` method to check for `NULLABLE` mode (#3620)
sonlac Jul 18, 2017
2767aa2
Fix "bad" storage unit tests. (#3627)
dhermes Jul 18, 2017
c565801
Add operation future (#3618)
Jul 19, 2017
827b41a
update the documentation link (#3630)
merla18 Jul 19, 2017
34bf003
Using assertIs in unit tests where appropriate. (#3629)
dhermes Jul 19, 2017
ada1cc3
update documentation link (#3633)
merla18 Jul 19, 2017
3d9461b
Fixing references to "dead" docs links. (#3631)
dhermes Jul 19, 2017
ffd7cca
Add keyword arguments to google.cloud.storage.Bucket.get_blob. (#3613)
tillahoffmann Jul 19, 2017
c262dbb
Removing JSON docs and unused images. (#3640)
dhermes Jul 20, 2017
14e570a
Changing all pypi.python.org links to warehouse links. (#3641)
dhermes Jul 20, 2017
419588c
Revert "RPC retries (second PR) (#3324)" (#3642)
Jul 20, 2017
4f4129d
Remove references to google.cloud.operation from spanner (#3625)
Jul 20, 2017
5ea61e4
Add Video Intelligence to README (#3628)
danoscarmike Jul 20, 2017
08021bd
Adding badge images to Video Intelligence README. (#3639)
dhermes Jul 20, 2017
6ff3725
Adding Bigtable Cluster location on create() request. (#3646)
dhermes Jul 20, 2017
1ed681b
Update bigtable to use future.operation (#3623)
Jul 20, 2017
2ed9426
Update auto-gen code for video intelligence (#3643)
lukesneeringer Jul 20, 2017
f8758df
Add systests for read/query w/ concurrent updates. (#3632)
tseaver Jul 20, 2017
c5ccca1
Switched to google-resumable-media in BigQuery. (#3555)
dhermes Jul 21, 2017
d2bc36d
Translate GA (#3650)
lukesneeringer Jul 21, 2017
6336e6c
Add Future interface to BigQuery jobs (#3626)
Jul 21, 2017
0414ef1
Removing vendored in google.cloud.streaming. (#3654)
dhermes Jul 21, 2017
d0479d6
Fix pylint for the main package
Jul 22, 2017
768d667
Revert "Fix pylint for the main package" - accidental push
Jul 22, 2017
506a304
Fix pylint for the main package (#3658)
Jul 24, 2017
40a3b49
Remove QueryJob.results() (#3661)
Jul 24, 2017
1598d5d
Split polling future into its own module (#3662)
Jul 24, 2017
c5922c6
Re-enable flake8 for core package and tests (#3664)
Jul 24, 2017
dd372df
Add systest for round-trip of NULL INT64. (#3665)
tseaver Jul 25, 2017
70088aa
Adding getter/setter note for Blob.metadata property. (#3647)
dhermes Jul 25, 2017
a88a334
Correctly url-encode list parameters (#3657)
isra17 Jul 25, 2017
c3ab2c0
Moving bytes signing helpers from `core` to `storage`. (#3668)
dhermes Jul 25, 2017
b56e8d4
Unbind transaction from session on commit/rollback. (#3669)
tseaver Jul 25, 2017
2083542
Removing `get_credentials()` from `core`. (#3667)
dhermes Jul 25, 2017
a813160
NL GAPIC (#3679)
lukesneeringer Jul 26, 2017
9cf5e9b
Cut release of vision API. (#3677)
dhermes Jul 26, 2017
86316d4
Auto-generated trace library (GAPIC only) (#3512)
liyanhui1228 Jul 26, 2017
9452572
Simplifying Client constructor's for Bigtable and Spanner. (#3672)
dhermes Jul 26, 2017
e273319
Implement multi-use snapshots (#3615)
tseaver Jul 26, 2017
7ff10be
Add trace docs to main docs index (#3683)
liyanhui1228 Jul 27, 2017
3144f10
Fix translate docs build. (#3688)
lukesneeringer Jul 27, 2017
440b214
Prep langauge-0.26.0 release.
tseaver Jul 26, 2017
09a476a
Alphabetize products for easier visual scanning. (#3682)
mbrukman Jul 27, 2017
6fff098
Merge branch 'language-release-0.26.0'
tseaver Jul 27, 2017
7d1161f
Remove httplib2, replace with Requests (#3674)
Jul 27, 2017
a1269a6
Create parameter type aliases for scalar field types. (#3670)
tseaver Jul 27, 2017
9d9b6c0
Appease current pylint opinions: (#3692)
tseaver Jul 27, 2017
597657e
Increment BQ DB-API thread safety. (#3693)
tswast Jul 27, 2017
b94a326
Added support for schema auto-detection feature in `LoadTableFromStor…
WillianFuks Jul 28, 2017
78e51d9
Add factories to ease creation of array / struct parameter types. (#3…
tseaver Jul 28, 2017
e89051f
Language GAPIC update (#3699)
lukesneeringer Jul 28, 2017
e59d305
Language 0.26.1 (#3701)
lukesneeringer Jul 28, 2017
d2fb6b6
Python GAPIC: Speech v1 (#3678)
lukesneeringer Jul 28, 2017
ce9cd83
Bump Speech to 0.27.1 (#3702)
lukesneeringer Jul 28, 2017
963d997
Allowing logging system tests to fail. (#3691)
dhermes Jul 31, 2017
6dc55fd
BigQuery & Storage: use client http for resumable media (#3705)
Jul 31, 2017
96f0cc3
Reduce the max tries for logging system tests (#3708)
liyanhui1228 Aug 1, 2017
ac23b77
Document deepcopy semantics of complex bucket properties. (#3712)
tseaver Aug 1, 2017
4de2450
Streaming directly into file on storage downloads. (#3713)
dhermes Aug 1, 2017
d0cfeb7
gcloud auth application-default is out of beta (#3716)
kennethmac2000 Aug 2, 2017
3e8d53c
Sprinkle majyk retry fairy dust. (#3720)
tseaver Aug 2, 2017
076ff00
Do not show Trace documentation. (#3719)
lukesneeringer Aug 4, 2017
6d7fae9
Add a function to complain about obselete packages. (#3724)
lukesneeringer Aug 4, 2017
2225289
Cutting release google-cloud-core==0.26.0. (#3727)
dhermes Aug 4, 2017
41f2d8d
Expanding the allowable descriptions for vision system tests. (#3729)
dhermes Aug 4, 2017
a31dd96
Add missing "packages" to sentence in ``core`` README. (#3728)
dhermes Aug 4, 2017
e835957
Updating all affected packages after google-cloud-core update. (#3730)
dhermes Aug 4, 2017
3012b5e
Using HTTPS wikipedia links in language system tests. (#3732)
dhermes Aug 5, 2017
289a961
fixed typo DETECTION (#3734)
bryanyang0528 Aug 7, 2017
da8a960
Add google.api.core package (#3726)
Aug 7, 2017
ac1b23b
Add 'update' API wrapper for buckets/blobs (#3714, #3715)
tseaver Aug 7, 2017
b09eda9
BigQuery: Remove client-side enum validation. (#3735)
lukesneeringer Aug 7, 2017
f034c61
Update storage to 1.3.1. (#3741)
dhermes Aug 7, 2017
c210494
Allow Table.read_rows to take an inclusive end key. (#3744)
lukesneeringer Aug 7, 2017
4bbdc6f
Explicitly depend on setuptools >= 34 (#3745)
lukesneeringer Aug 7, 2017
1656ffc
Update broken links to video intelligence docs in package README (#3458)
endast Aug 7, 2017
10466d1
Bump requests minimum bound to 2.18.0 (#3748)
lukesneeringer Aug 7, 2017
1b764b8
Add 'Table.row_from_mapping' helper. (#3425)
tseaver Aug 7, 2017
45ee4bd
Reuse explicit credentials when creating 'database.spanner_api'. (#3722)
tseaver Aug 7, 2017
26214d2
Update trace dependencies to fix the unit test (#3749)
liyanhui1228 Aug 7, 2017
b96eaca
Make CONTRIBUTING.rst be up to date. (#3750)
lukesneeringer Aug 8, 2017
fe757be
session.run_in_transaction returns the callback's return value. (#3753)
lukesneeringer Aug 8, 2017
abfec70
Add google.api.core.exceptions (#3738)
Aug 8, 2017
90e6fe7
Bump GAX dependency to 0.15.14. (#3752)
lukesneeringer Aug 8, 2017
aaaaf7d
Reference valid input formats in API docs. (#3758)
lukesneeringer Aug 8, 2017
1ff7708
Make exclude_from_indexes a set, and public API. (#3756)
lukesneeringer Aug 8, 2017
cdadf4c
Move google.cloud.future to google.api.core (#3764)
Aug 8, 2017
90834d1
Use latest/ directory for docs instead of stable/ (#3766)
tswast Aug 8, 2017
b242099
Fix __eq__ and __ne__. (#3765)
lukesneeringer Aug 8, 2017
15ed5e7
Increase backoff to fix monitoring system test (#3769)
liyanhui1228 Aug 9, 2017
c24123c
Move google.cloud.iterator to google.api.core.page_iterator (#3770)
Aug 9, 2017
1fcd53d
nullMarker support for BigQuery Load Jobs (#3449) (#3777)
Aug 9, 2017
a1942ba
Allow job_id to be explicitly specified. (#3779)
lukesneeringer Aug 9, 2017
5b4b8fa
De-flake the snapshot system test. (#3780)
lukesneeringer Aug 9, 2017
1fcc1a4
Add a test which provokes abort-during-read during 'run_in_transacti…
tseaver Aug 10, 2017
69dc45a
Add support for a custom null marker. (#3776)
lukesneeringer Aug 10, 2017
1d08991
Document to_legacy_urlsafe as being equivalent to ndb. (#3783)
lukesneeringer Aug 10, 2017
87a46a8
Block creation of transaction for session w/ existing txn. (#3785)
tseaver Aug 10, 2017
957f6e0
Add SchemaField serialization and deserialization. (#3786)
lukesneeringer Aug 10, 2017
64d1728
Storage: Track deleted labels; make Bucket.patch() send them. (#3737)
lukesneeringer Aug 10, 2017
ebecc7d
Drop 'Database.read' and 'Database.execute_sql' convenience methods. …
tseaver Aug 10, 2017
19e9579
Update spanner docs to show correct 'Batch.delete' usage.
tseaver Aug 10, 2017
edc7c27
Prevent nested transactions. (#3789)
lukesneeringer Aug 10, 2017
5145022
Wait for load jobs to complete in system tests. (#3782)
tswast Aug 11, 2017
4817fb7
Document retry of exceptions while streaming 'read'/'execute_sql' res…
tseaver Aug 11, 2017
6c15d81
Make the Spanner README better. (#3791)
lukesneeringer Aug 11, 2017
7e960e6
Add a .one and .one_or_none method. (#3784)
lukesneeringer Aug 11, 2017
d750a13
Drop 'Session' as a promoted, top-level entity in docs. (#3792)
tseaver Aug 11, 2017
09b0cb7
Make Datastore doctests use a namespace. (#3793)
lukesneeringer Aug 11, 2017
ba4e8c8
Accurately document system test permissions. (#3795)
lukesneeringer Aug 11, 2017
c33e9d4
Make unsigned credentials error DRY. (#3794)
lukesneeringer Aug 11, 2017
cd3a05d
Fix Spanner README. (#3796)
lukesneeringer Aug 11, 2017
0723a9c
Update README.rst (#3805)
alanyee Aug 14, 2017
3facccb
Update reference to bytes signing issue in blob.py (#3816)
alanyee Aug 15, 2017
75f0a09
Fix doc build by swapping install order (#3828)
Aug 16, 2017
d7b625c
Add google.api.core.retry with base retry functionality (#3819)
Aug 16, 2017
13cdb0c
Dropping umbrella package from nox docs sessions. (#3829)
dhermes Aug 16, 2017
36304f7
Add google.api.core.retry.Retry decorator (#3835)
Aug 17, 2017
fbda27c
Drop tenacity dependency; use google.api.core.retry in google.api.cor…
Aug 18, 2017
df37095
Fix documentation link. (#3825)
lukesneeringer Aug 18, 2017
813b534
Fix broken link in Speech README. (#3821)
jybaek Aug 18, 2017
406ecad
Add google.api.page_iterator.GRPCIterator (#3843)
Aug 18, 2017
7a8f5a9
BigQuery - add get_query_results method. (#3838)
tswast Aug 18, 2017
5efa4bb
BigQuery: Poll via getQueryResults method. (#3844)
tswast Aug 21, 2017
f67bea4
Allow fetching more than the first page when max_results is set. (#3845)
tswast Aug 21, 2017
7b2f9c2
DLP: Regeneration
landrito Aug 21, 2017
db48c3b
Hand edits
landrito Aug 21, 2017
66ad48c
Review fixes.
landrito Aug 22, 2017
53fd41c
Merge branch 'master' of github.com:googlecloudplatform/google-cloud-…
landrito Aug 22, 2017
38aa94e
Add dlp to CI
landrito Aug 22, 2017
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
Prev Previous commit
Next Next commit
Adding optional switch to capture project ID in from_service_account_…
…json(). (#3436)

Fixes #1883.
  • Loading branch information
dhermes authored Jun 6, 2017
commit a55010fb5a38601161624a5e9b645889b4df9045
1 change: 1 addition & 0 deletions bigtable/google/cloud/bigtable/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class Client(_ClientFactoryMixin, _ClientProjectMixin):
_instance_stub_internal = None
_operations_stub_internal = None
_table_stub_internal = None
_SET_PROJECT = True # Used by from_service_account_json()

def __init__(self, project=None, credentials=None,
read_only=False, admin=False, user_agent=DEFAULT_USER_AGENT):
Expand Down
18 changes: 15 additions & 3 deletions core/google/cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

"""Base classes for client used to interact with Google Cloud APIs."""

import io
import json
from pickle import PicklingError

import google.auth.credentials
Expand All @@ -40,6 +42,8 @@ class _ClientFactoryMixin(object):
This class is virtual.
"""

_SET_PROJECT = False

@classmethod
def from_service_account_json(cls, json_credentials_path, *args, **kwargs):
"""Factory to retrieve JSON credentials while creating client.
Expand All @@ -58,15 +62,21 @@ def from_service_account_json(cls, json_credentials_path, *args, **kwargs):
:type kwargs: dict
:param kwargs: Remaining keyword arguments to pass to constructor.

:rtype: :class:`google.cloud.pubsub.client.Client`
:rtype: :class:`_ClientFactoryMixin`
:returns: The client created with the retrieved JSON credentials.
:raises: :class:`TypeError` if there is a conflict with the kwargs
and the credentials created by the factory.
"""
if 'credentials' in kwargs:
raise TypeError('credentials must not be in keyword arguments')
credentials = service_account.Credentials.from_service_account_file(
json_credentials_path)
with io.open(json_credentials_path, 'r', encoding='utf-8') as json_fi:
credentials_info = json.load(json_fi)
credentials = service_account.Credentials.from_service_account_info(
credentials_info)
if cls._SET_PROJECT:
if 'project' not in kwargs:
kwargs['project'] = credentials_info.get('project_id')

kwargs['credentials'] = credentials
return cls(*args, **kwargs)

Expand Down Expand Up @@ -207,6 +217,8 @@ class ClientWithProject(Client, _ClientProjectMixin):
set in the environment.
"""

_SET_PROJECT = True # Used by from_service_account_json()

def __init__(self, project=None, credentials=None, _http=None):
_ClientProjectMixin.__init__(self, project=project)
Client.__init__(self, credentials=credentials, _http=_http)
3 changes: 2 additions & 1 deletion core/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def unit_tests(session, python_version):
session.install('-e', '.')

# Run py.test against the unit tests.
session.run('py.test', '--quiet',
session.run(
'py.test', '--quiet',
'--cov=google.cloud', '--cov=tests.unit', '--cov-append',
'--cov-config=.coveragerc', '--cov-report=', '--cov-fail-under=97',
'tests/unit',
Expand Down
69 changes: 63 additions & 6 deletions core/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import io
import json
import unittest

import mock
Expand Down Expand Up @@ -90,21 +92,32 @@ def test_ctor_bad_credentials(self):
self._make_one(credentials=CREDENTIALS)

def test_from_service_account_json(self):
KLASS = self._get_target_class()
from google.cloud import _helpers

klass = self._get_target_class()

# Mock both the file opening and the credentials constructor.
info = {'dummy': 'value', 'valid': 'json'}
json_fi = io.StringIO(_helpers._bytes_to_unicode(json.dumps(info)))
file_open_patch = mock.patch(
'io.open', return_value=json_fi)
constructor_patch = mock.patch(
'google.oauth2.service_account.Credentials.'
'from_service_account_file',
'from_service_account_info',
return_value=_make_credentials())

with constructor_patch as constructor:
client_obj = KLASS.from_service_account_json(
mock.sentinel.filename)
with file_open_patch as file_open:
with constructor_patch as constructor:
client_obj = klass.from_service_account_json(
mock.sentinel.filename)

self.assertIs(
client_obj._credentials, constructor.return_value)
self.assertIsNone(client_obj._http_internal)
constructor.assert_called_once_with(mock.sentinel.filename)
# Check that mocks were called as expected.
file_open.assert_called_once_with(
mock.sentinel.filename, 'r', encoding='utf-8')
constructor.assert_called_once_with(info)

def test_from_service_account_json_bad_args(self):
KLASS = self._get_target_class()
Expand Down Expand Up @@ -221,3 +234,47 @@ def test_ctor_explicit_bytes(self):
def test_ctor_explicit_unicode(self):
PROJECT = u'PROJECT'
self._explicit_ctor_helper(PROJECT)

def _from_service_account_json_helper(self, project=None):
from google.cloud import _helpers

klass = self._get_target_class()

info = {'dummy': 'value', 'valid': 'json'}
if project is None:
expected_project = 'eye-d-of-project'
else:
expected_project = project

info['project_id'] = expected_project
# Mock both the file opening and the credentials constructor.
json_fi = io.StringIO(_helpers._bytes_to_unicode(json.dumps(info)))
file_open_patch = mock.patch(
'io.open', return_value=json_fi)
constructor_patch = mock.patch(
'google.oauth2.service_account.Credentials.'
'from_service_account_info',
return_value=_make_credentials())

with file_open_patch as file_open:
with constructor_patch as constructor:
kwargs = {}
if project is not None:
kwargs['project'] = project
client_obj = klass.from_service_account_json(
mock.sentinel.filename, **kwargs)

self.assertIs(
client_obj._credentials, constructor.return_value)
self.assertIsNone(client_obj._http_internal)
self.assertEqual(client_obj.project, expected_project)
# Check that mocks were called as expected.
file_open.assert_called_once_with(
mock.sentinel.filename, 'r', encoding='utf-8')
constructor.assert_called_once_with(info)

def test_from_service_account_json(self):
self._from_service_account_json_helper()

def test_from_service_account_json_project_set(self):
self._from_service_account_json_helper(project='prah-jekt')
1 change: 1 addition & 0 deletions spanner/google/cloud/spanner/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Client(_ClientFactoryMixin, _ClientProjectMixin):
"""
_instance_admin_api = None
_database_admin_api = None
_SET_PROJECT = True # Used by from_service_account_json()

def __init__(self, project=None, credentials=None,
user_agent=DEFAULT_USER_AGENT):
Expand Down