| https://github.com/requests/requests-oauthlib/commit/7057cbee773c1dff1856730ca661cc71abb2506e.diff |
| https://github.com/requests/requests-oauthlib/commit/8c2c96c4bb45803df2779cfde90868445977ab96.diff |
| diff --git a/tests/test_oauth2_session.py b/tests/test_oauth2_session.py |
| index 305241a..cf095a5 100644 |
| --- a/tests/test_oauth2_session.py |
| +++ b/tests/test_oauth2_session.py |
| @@ -1,6 +1,7 @@ |
| from __future__ import unicode_literals |
| import json |
| import mock |
| +import time |
| import unittest |
| |
| from oauthlib.common import urlencode |
| @@ -11,6 +11,9 @@ |
| from requests_oauthlib import OAuth2Session, TokenUpdated |
| |
| |
| +fake_time = time.time() |
| + |
| + |
| class OAuth2SessionTest(unittest.TestCase): |
| |
| def setUp(self): |
| @@ -22,7 +25,8 @@ def setUp(self): |
| 'token_type': 'Bearer', |
| 'access_token': 'asdfoiw37850234lkjsdfsdf', |
| 'refresh_token': 'sldvafkjw34509s8dfsdf', |
| - 'expires_in': '3600' |
| + 'expires_in': '3600', |
| + 'expires_at': fake_time + 3600, |
| } |
| self.client_id = 'foo' |
| self.clients = [ |
| @@ -66,9 +70,11 @@ def test_authorization_url(self): |
| self.assertIn(self.client_id, auth_url) |
| self.assertIn('response_type=token', auth_url) |
| |
| + @mock.patch("time.time", new=lambda: fake_time) |
| def test_refresh_token_request(self): |
| self.expired_token = dict(self.token) |
| self.expired_token['expires_in'] = '-1' |
| + del self.expired_token['expires_at'] |
| |
| def fake_refresh(r, **kwargs): |
| resp = mock.MagicMock() |
| @@ -98,12 +104,14 @@ def token_updater(token): |
| auth.send = fake_refresh |
| auth.get('https://i.b') |
| |
| + @mock.patch("time.time", new=lambda: fake_time) |
| def test_token_from_fragment(self): |
| mobile = MobileApplicationClient(self.client_id) |
| response_url = 'https://i.b/callback#' + urlencode(self.token.items()) |
| auth = OAuth2Session(client=mobile) |
| self.assertEqual(auth.token_from_fragment(response_url), self.token) |
| |
| + @mock.patch("time.time", new=lambda: fake_time) |
| def test_fetch_token(self): |
| def fake_token(token): |
| def fake_send(r, **kwargs): |