Private
Public Access
1
0

updated tests

This commit is contained in:
Sander Roosendaal
2018-06-26 22:00:57 +02:00
parent e0dd903d68
commit ac0fc4a355
3 changed files with 23 additions and 6 deletions

View File

@@ -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):

View File

@@ -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)

View File

@@ -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):