Merge "Prepare Google Backup driver for latest libraries"

This commit is contained in:
Zuul 2018-07-18 17:45:19 +00:00 committed by Gerrit Code Review
commit 3ec497ccd9
2 changed files with 12 additions and 1 deletions

View File

@ -166,7 +166,8 @@ class GoogleBackupDriver(chunkeddriver.ChunkedBackupDriver):
creds = service_account.Credentials.from_service_account_file(
backup_credential)
OAUTH_EXCEPTIONS = (gexceptions.RefreshError,
gexceptions.DefaultCredentialsError)
gexceptions.DefaultCredentialsError,
client.Error)
# Can't use google-auth, use deprecated oauth2client
else:

View File

@ -76,6 +76,11 @@ def gcs_client(func):
fake_google_client.FakeGoogleMediaIoBaseDownload)
@mock.patch.object(hashlib, 'md5', FakeMD5)
def func_wrapper(self, *args, **kwargs):
if google_dr.service_account:
with mock.patch.object(google_dr.service_account.Credentials,
'from_service_account_file',
fake_google_client.FakeGoogleCredentials):
return func(self, *args, **kwargs)
return func(self, *args, **kwargs)
return func_wrapper
@ -93,6 +98,11 @@ def gcs_client2(func):
FakeObjectName._fake_generate_object_name_prefix)
@mock.patch.object(hashlib, 'md5', FakeMD5)
def func_wrapper(self, *args, **kwargs):
if google_dr.service_account:
with mock.patch.object(google_dr.service_account.Credentials,
'from_service_account_file',
fake_google_client.FakeGoogleCredentials):
return func(self, *args, **kwargs)
return func(self, *args, **kwargs)
return func_wrapper