Private
Public Access
1
0

making tests run

This commit is contained in:
Sander Roosendaal
2018-11-14 08:43:24 +01:00
parent dddc1e9224
commit a524d65fe2
4 changed files with 16 additions and 5 deletions

View File

@@ -102,7 +102,7 @@ def imports_open(user,oauth_data):
expirydatename,
oauth_data,
)
elif tokenexpirydate is None and 'strava' in expirydatename:
elif tokenexpirydate is None and expirydatename is not None and 'strava' in expirydatename:
token = imports_token_refresh(
user,
tokenname,

View File

@@ -102,6 +102,7 @@ def get_strava_workout_list(user,limit_n=0):
s = requests.get(url,headers=headers,params=params)
return s

View File

@@ -321,6 +321,15 @@ def mocked_requests(*args, **kwargs):
return MockResponse(json_data,200)
elif stravasummarytester.match(args[0]):
return MockResponse(stravasummaryjson,200)
elif 'token' in args[0]:
json_data = {
"token_type": "Bearer",
"access_token": "987654321234567898765432123456789",
"refresh_token": "1234567898765432112345678987654321",
"expires_at": 1531385304
}
return MockResponse(json_data,200)
if c2tester.match(args[0]):
if c2uploadtester.match(args[0]):

View File

@@ -10276,20 +10276,21 @@ def workout_add_chart_view(request,id,plotnr=1):
# The page where you select which Strava workout to import
@login_required()
def workout_stravaimport_view(request,message="",userid=0):
res = stravastuff.get_strava_workout_list(request.user)
r = getrequestrower(request,userid=userid)
try:
thetoken = strava_open(request.user)
except NoTokenError:
return HttpResponseRedirect("/rowers/me/stravaauthorize/")
res = stravastuff.get_strava_workout_list(request.user)
r = getrequestrower(request,userid=userid)
if r.user != request.user:
messages.info(request,"You cannot import other people's workouts from Concept2")
r = getrower(request.user)
if (res.status_code != 200):
if (res.status_code == 401):
r = getrower(request.user)