updated tests
This commit is contained in:
@@ -184,11 +184,14 @@ def imports_get_token(
|
|||||||
if response.status_code == 200 or response.status_code == 201:
|
if response.status_code == 200 or response.status_code == 201:
|
||||||
token_json = response.json()
|
token_json = response.json()
|
||||||
thetoken = token_json['access_token']
|
thetoken = token_json['access_token']
|
||||||
expires_in = token_json['expires_in']
|
|
||||||
try:
|
try:
|
||||||
refresh_token = token_json['refresh_token']
|
refresh_token = token_json['refresh_token']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
refresh_token = refreshtoken
|
refresh_token = ''
|
||||||
|
try:
|
||||||
|
expires_in = token_json['expires_in']
|
||||||
|
except KeyError:
|
||||||
|
expires_in = 0
|
||||||
try:
|
try:
|
||||||
expires_in = int(expires_in)
|
expires_in = int(expires_in)
|
||||||
except (ValueError,TypeError):
|
except (ValueError,TypeError):
|
||||||
|
|||||||
@@ -26,6 +26,20 @@ except ImportError:
|
|||||||
|
|
||||||
from rowers.imports import *
|
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
|
# Exchange access code for long-lived access token
|
||||||
def get_token(code):
|
def get_token(code):
|
||||||
client_auth = requests.auth.HTTPBasicAuth(STRAVA_CLIENT_ID, STRAVA_CLIENT_SECRET)
|
client_auth = requests.auth.HTTPBasicAuth(STRAVA_CLIENT_ID, STRAVA_CLIENT_SECRET)
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ class STObjects(DjangoTestCase):
|
|||||||
with open('rowers/testdata/sporttrackstestdata.txt','r') as infile:
|
with open('rowers/testdata/sporttrackstestdata.txt','r') as infile:
|
||||||
data = json.load(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',
|
u = User.objects.create_user('john',
|
||||||
'sander@ds.ds',
|
'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):
|
def test_strokedatanohr(self):
|
||||||
with open('rowers/testdata/sporttrackstestnohr.txt','r') as infile:
|
with open('rowers/testdata/sporttrackstestnohr.txt','r') as infile:
|
||||||
data = json.load(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',
|
u = User.objects.create_user('john',
|
||||||
'sander@ds.ds',
|
'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):
|
class TestErrorPages(TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user