From ac0fc4a35598c87ee98b9e79d01a9f1ce5a478fb Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 26 Jun 2018 22:00:57 +0200 Subject: [PATCH] updated tests --- rowers/imports.py | 7 +++++-- rowers/stravastuff.py | 14 ++++++++++++++ rowers/tests.py | 8 ++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/rowers/imports.py b/rowers/imports.py index b5f5080a..58ed3a69 100644 --- a/rowers/imports.py +++ b/rowers/imports.py @@ -184,11 +184,14 @@ def imports_get_token( if response.status_code == 200 or response.status_code == 201: token_json = response.json() thetoken = token_json['access_token'] - expires_in = token_json['expires_in'] try: refresh_token = token_json['refresh_token'] except KeyError: - refresh_token = refreshtoken + refresh_token = '' + try: + expires_in = token_json['expires_in'] + except KeyError: + expires_in = 0 try: expires_in = int(expires_in) except (ValueError,TypeError): diff --git a/rowers/stravastuff.py b/rowers/stravastuff.py index 206163ce..ddc002dd 100644 --- a/rowers/stravastuff.py +++ b/rowers/stravastuff.py @@ -26,6 +26,20 @@ except ImportError: from rowers.imports import * +oauth_data = { + 'client_id': STRAVA_CLIENT_ID, + 'client_secret': STRAVA_CLIENT_SECRET, + 'redirect_uri': STRAVA_REDIRECT_URI, + 'autorization_uri': "https://www.strava.com/oauth/authorize", + 'content_type': 'application/json', + 'tokenname': 'stravatoken', + 'refreshtokenname': '', + 'expirydatename': '', + 'bearer_auth': True, + 'base_url': "https://www.strava.com/oauth/token", + } + + # Exchange access code for long-lived access token def get_token(code): client_auth = requests.auth.HTTPBasicAuth(STRAVA_CLIENT_ID, STRAVA_CLIENT_SECRET) diff --git a/rowers/tests.py b/rowers/tests.py index bbdcc5ef..24b6f70a 100644 --- a/rowers/tests.py +++ b/rowers/tests.py @@ -269,7 +269,7 @@ class STObjects(DjangoTestCase): with open('rowers/testdata/sporttrackstestdata.txt','r') as infile: data = json.load(infile) - from rowers.views import add_workout_from_stdata + from rowers.sporttracksstuff import add_workout_from_data u = User.objects.create_user('john', 'sander@ds.ds', @@ -279,13 +279,13 @@ class STObjects(DjangoTestCase): ) - res = add_workout_from_stdata(u,1,data) + res = add_workout_from_data(u,1,data,data) def test_strokedatanohr(self): with open('rowers/testdata/sporttrackstestnohr.txt','r') as infile: data = json.load(infile) - from rowers.views import add_workout_from_stdata + from rowers.sporttracksstuff import add_workout_from_data u = User.objects.create_user('john', 'sander@ds.ds', @@ -296,7 +296,7 @@ class STObjects(DjangoTestCase): ) - res = add_workout_from_stdata(u,1,data) + res = add_workout_from_data(u,1,data,data) class TestErrorPages(TestCase):