Private
Public Access
1
0

coverage related changes

This commit is contained in:
Sander Roosendaal
2021-04-26 17:48:22 +02:00
parent 7626554ba9
commit 9e2a97e721
17 changed files with 1534 additions and 144 deletions

View File

@@ -43,7 +43,7 @@ TEST_CLIENT_SECRET = "aapnootmies"
TEST_REDIRECT_URI = "http://localhost:8000/rowers/test_callback"
def custom_exception_handler(exc,message):
def custom_exception_handler(exc,message): # pragma: no cover
response = {
"errors": [
@@ -60,7 +60,7 @@ def custom_exception_handler(exc,message):
return res
def do_refresh_token(refreshtoken):
def do_refresh_token(refreshtoken): # pragma: no cover
client_auth = requests.auth.HTTPBasicAuth(TEST_CLIENT_ID, TEST_CLIENT_SECRET)
post_data = {"grant_type": "refresh_token",
"client_secret": TEST_CLIENT_SECRET,
@@ -88,7 +88,7 @@ def do_refresh_token(refreshtoken):
return [thetoken,expires_in,refresh_token]
def get_token(code):
def get_token(code): # pragma: no cover
client_auth = requests.auth.HTTPBasicAuth(TEST_CLIENT_ID, TEST_CLIENT_SECRET)
post_data = {"grant_type": "authorization_code",
"code": code,
@@ -114,7 +114,7 @@ def get_token(code):
return [thetoken,expires_in,refresh_token]
def make_authorization_url(request):
def make_authorization_url(request): # pragma: no cover
# Generate a random string for the state parameter
# Save it for use later to prevent xsrf attacks
from uuid import uuid4
@@ -133,7 +133,7 @@ def make_authorization_url(request):
return HttpResponseRedirect(url)
def rower_ownapi_token_refresh(user):
def rower_ownapi_token_refresh(user): # pragma: no cover
r = Rower.objects.get(user=user)
res = do_refresh_token(r.ownapirefreshtoken)
access_token = res[0]
@@ -149,7 +149,7 @@ def rower_ownapi_token_refresh(user):
r.save()
return r.ownapitoken
def get_ownapi_workout_list(user):
def get_ownapi_workout_list(user): # pragma: no cover
r = Rower.objects.get(user=user)
if (r.ownapitoken == '') or (r.ownapitoken is None):
s = "Token doesn't exist. Need to authorize"
@@ -169,7 +169,7 @@ def get_ownapi_workout_list(user):
return s
def get_ownapi_workout(user,ownapiid):
def get_ownapi_workout(user,ownapiid): # pragma: no cover
r = Rower.objects.get(user=user)
if (r.ownapitoken == '') or (r.ownapitoken is None):
return custom_exception_handler(401,s)
@@ -188,7 +188,7 @@ def get_ownapi_workout(user,ownapiid):
return s
def createownapiworkoutdata(w):
def createownapiworkoutdata(w): # pragma: no cover
filename = w.csvfilename
row = rowingdata(csvfile=filename)
averagehr = int(row.df[' HRCur (bpm)'].mean())
@@ -277,7 +277,7 @@ def createownapiworkoutdata(w):
return data
def getidfromresponse(response):
def getidfromresponse(response): # pragma: no cover
t = json.loads(response.text)
uri = t['uris'][0]
id = uri[len(uri)-13:len(uri)-5]