aboutsummaryrefslogtreecommitdiff
path: root/tests/test_service_account.py
diff options
context:
space:
mode:
authorOrest Bolohan <orest@google.com>2014-06-03 10:39:19 -0700
committerOrest Bolohan <orest@google.com>2014-06-03 10:39:19 -0700
commit4bcd15ed0e0b672bdd6d17ef950366c7d8a9b157 (patch)
treee2751764bcc2050f1b246b683a045b229d4e0753 /tests/test_service_account.py
parente0c51b98dd18a3a878560ada983eec221419168d (diff)
downloadoauth2client-4bcd15ed0e0b672bdd6d17ef950366c7d8a9b157.tar.gz
Tweak the computation of seconds from a datetime.timedelta object, so
that we consider only the whole seconds.
Diffstat (limited to 'tests/test_service_account.py')
-rw-r--r--tests/test_service_account.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/test_service_account.py b/tests/test_service_account.py
index 952483c..56313d3 100644
--- a/tests/test_service_account.py
+++ b/tests/test_service_account.py
@@ -94,8 +94,9 @@ class ServiceAccountCredentialsTests(unittest.TestCase):
self.assertEqual('dummy_scope', new_credentials._scopes)
def test_access_token(self):
- token_response_first = {'access_token': 'first_token', 'expires_in': 1}
- token_response_second = {'access_token': 'second_token', 'expires_in': 1}
+ S = 2 # number of seconds in which the token expires
+ token_response_first = {'access_token': 'first_token', 'expires_in': S}
+ token_response_second = {'access_token': 'second_token', 'expires_in': S}
http = HttpMockSequence([
({'status': '200'}, simplejson.dumps(token_response_first)),
({'status': '200'}, simplejson.dumps(token_response_second)),
@@ -103,21 +104,21 @@ class ServiceAccountCredentialsTests(unittest.TestCase):
token = self.credentials.get_access_token(http=http)
self.assertEqual('first_token', token.access_token)
- self.assertEqual(1, token.expires_in)
+ self.assertEqual(S - 1, token.expires_in)
self.assertFalse(self.credentials.access_token_expired)
self.assertEqual(token_response_first, self.credentials.token_response)
token = self.credentials.get_access_token(http=http)
self.assertEqual('first_token', token.access_token)
- self.assertEqual(1, token.expires_in)
+ self.assertEqual(S - 1, token.expires_in)
self.assertFalse(self.credentials.access_token_expired)
self.assertEqual(token_response_first, self.credentials.token_response)
- time.sleep(1)
+ time.sleep(S)
self.assertTrue(self.credentials.access_token_expired)
token = self.credentials.get_access_token(http=http)
self.assertEqual('second_token', token.access_token)
- self.assertEqual(1, token.expires_in)
+ self.assertEqual(S - 1, token.expires_in)
self.assertFalse(self.credentials.access_token_expired)
self.assertEqual(token_response_second, self.credentials.token_response)