Private
Public Access
1
0

mocking c2import successfully

This commit is contained in:
Sander Roosendaal
2018-07-01 13:23:24 +02:00
parent e8dd12c8b8
commit cbaada7945
11 changed files with 1804 additions and 57 deletions

View File

@@ -517,10 +517,10 @@ def get_workout(user,c2id):
r = Rower.objects.get(user=user)
if (r.c2token == '') or (r.c2token is None):
s = "Token doesn't exist. Need to authorize"
return custom_exception_handler(401,s)
return custom_exception_handler(401,s) ,0
elif (timezone.now()>r.tokenexpirydate):
s = "Token expired. Needs to refresh."
return custom_exception_handler(401,s)
return custom_exception_handler(401,s),0
else:
# ready to fetch. Hurray
authorizationstring = str('Bearer ' + r.c2token)
@@ -530,6 +530,7 @@ def get_workout(user,c2id):
url = "https://log.concept2.com/api/users/me/results/"+str(c2id)
s = requests.get(url,headers=headers)
data = s.json()['data']
splitdata = None
@@ -544,6 +545,8 @@ def get_workout(user,c2id):
res2 = get_c2_workout_strokes(user,c2id)
if res2.status_code == 200:
strokedata = pd.DataFrame.from_dict(res2.json()['data'])
else:
strokedata = pd.DataFrame()
else:
strokedata = pd.DataFrame()