Clean up whitespace

This commit is contained in:
Pat Ferate
2016-07-08 10:24:21 -07:00
parent 514c170746
commit 1934bfb179
14 changed files with 49 additions and 55 deletions

View File

@@ -1257,7 +1257,6 @@ class GoogleCredentials(OAuth2Credentials):
data['_class'] == '_JWTAccessCredentials'): data['_class'] == '_JWTAccessCredentials'):
return _JWTAccessCredentials.from_json(data) return _JWTAccessCredentials.from_json(data)
token_expiry = _parse_expiry(data.get('token_expiry')) token_expiry = _parse_expiry(data.get('token_expiry'))
google_credentials = cls( google_credentials = cls(
data['access_token'], data['access_token'],
@@ -1466,8 +1465,7 @@ def save_to_well_known_file(credentials, well_known_file=None):
def _get_environment_variable_file(): def _get_environment_variable_file():
application_default_credential_filename = ( application_default_credential_filename = (
os.environ.get(GOOGLE_APPLICATION_CREDENTIALS, os.environ.get(GOOGLE_APPLICATION_CREDENTIALS, None))
None))
if application_default_credential_filename: if application_default_credential_filename:
if os.path.isfile(application_default_credential_filename): if os.path.isfile(application_default_credential_filename):

View File

@@ -290,8 +290,8 @@ class UserOAuth2(object):
def has_credentials(self): def has_credentials(self):
"""Returns True if there are valid credentials for the current user """Returns True if there are valid credentials for the current user
and required scopes.""" and required scopes."""
return (self.credentials and not self.credentials.invalid return (self.credentials and not self.credentials.invalid and
and self.credentials.has_scopes(self.scopes)) self.credentials.has_scopes(self.scopes))
@property @property
def credentials(self): def credentials(self):

View File

@@ -446,8 +446,8 @@ class UserOAuth2(object):
if not self.credentials: if not self.credentials:
return False return False
# Is the access token expired? If so, do we have an refresh token? # Is the access token expired? If so, do we have an refresh token?
elif (self.credentials.access_token_expired elif (self.credentials.access_token_expired and
and not self.credentials.refresh_token): not self.credentials.refresh_token):
return False return False
else: else:
return True return True

View File

@@ -242,9 +242,8 @@ class Oauth2AuthorizeTest(TestWithSession):
self.assertTrue(isinstance(response, http.HttpResponseRedirect)) self.assertTrue(isinstance(response, http.HttpResponseRedirect))
def test_authorize_works_explicit_return_url(self): def test_authorize_works_explicit_return_url(self):
request = self.factory.get('oauth2/oauth2authorize', data={ request = self.factory.get('oauth2/oauth2authorize',
'return_url': '/return_endpoint' data={'return_url': '/return_endpoint'})
})
request.session = self.session request.session = self.session
response = views.oauth2_authorize(request) response = views.oauth2_authorize(request)
self.assertTrue(isinstance(response, http.HttpResponseRedirect)) self.assertTrue(isinstance(response, http.HttpResponseRedirect))

View File

@@ -36,6 +36,7 @@ SERVICE_ACCOUNT_INFO = {
'aliases': ['default'] 'aliases': ['default']
} }
class AppAssertionCredentialsTests(unittest2.TestCase): class AppAssertionCredentialsTests(unittest2.TestCase):
def test_constructor(self): def test_constructor(self):

View File

@@ -171,6 +171,7 @@ class Test__check_audience(unittest2.TestCase):
with self.assertRaises(crypt.AppIdentityError): with self.assertRaises(crypt.AppIdentityError):
crypt._check_audience(payload_dict, audience2) crypt._check_audience(payload_dict, audience2)
class Test__verify_time_range(unittest2.TestCase): class Test__verify_time_range(unittest2.TestCase):
def _exception_helper(self, payload_dict): def _exception_helper(self, payload_dict):

View File

@@ -435,8 +435,8 @@ class JWTAccessCredentialsTests(unittest2.TestCase):
utcnow.return_value = T1_DATE utcnow.return_value = T1_DATE
time.return_value = T1 time.return_value = T1
token_info = self.jwt.get_access_token(additional_claims= token_info = self.jwt.get_access_token(
{'aud': 'https://test2.url.com', additional_claims={'aud': 'https://test2.url.com',
'sub': 'dummy2@google.com' 'sub': 'dummy2@google.com'
}) })
payload = crypt.verify_signed_jwt_with_certs( payload = crypt.verify_signed_jwt_with_certs(

View File

@@ -71,8 +71,7 @@ class TestRunFlow(unittest2.TestCase):
auth_host_port=[8080, ], auth_host_port=[8080, ],
auth_host_name='localhost') auth_host_name='localhost')
@mock.patch.object(sys, 'argv', @mock.patch.object(sys, 'argv', ['ignored', '--noauth_local_webserver'])
['ignored', '--noauth_local_webserver'])
@mock.patch('oauth2client.tools.logging') @mock.patch('oauth2client.tools.logging')
@mock.patch('oauth2client.tools.input') @mock.patch('oauth2client.tools.input')
def test_run_flow_no_webserver(self, input_mock, logging_mock): def test_run_flow_no_webserver(self, input_mock, logging_mock):

View File

@@ -9,7 +9,6 @@ from oauth2client import util
__author__ = 'jcgregorio@google.com (Joe Gregorio)' __author__ = 'jcgregorio@google.com (Joe Gregorio)'
class PositionalTests(unittest2.TestCase): class PositionalTests(unittest2.TestCase):
def test_usage(self): def test_usage(self):
@@ -45,7 +44,6 @@ class PositionalTests(unittest2.TestCase):
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
fn3(1, 2) fn3(1, 2)
@mock.patch('oauth2client.util.logger') @mock.patch('oauth2client.util.logger')
def test_enforcement_warning(self, mock_logger): def test_enforcement_warning(self, mock_logger):
util.positional_parameters_enforcement = util.POSITIONAL_WARNING util.positional_parameters_enforcement = util.POSITIONAL_WARNING
@@ -57,7 +55,6 @@ class PositionalTests(unittest2.TestCase):
self.assertTrue(fn(1, 2)) self.assertTrue(fn(1, 2))
self.assertTrue(mock_logger.warning.called) self.assertTrue(mock_logger.warning.called)
@mock.patch('oauth2client.util.logger') @mock.patch('oauth2client.util.logger')
def test_enforcement_ignore(self, mock_logger): def test_enforcement_ignore(self, mock_logger):
util.positional_parameters_enforcement = util.POSITIONAL_IGNORE util.positional_parameters_enforcement = util.POSITIONAL_IGNORE
@@ -104,7 +101,6 @@ class StringToScopeTests(unittest2.TestCase):
self.assertEqual(expected, util.string_to_scopes(case)) self.assertEqual(expected, util.string_to_scopes(case))
class AddQueryParameterTests(unittest2.TestCase): class AddQueryParameterTests(unittest2.TestCase):
def test__add_query_parameter(self): def test__add_query_parameter(self):