Private
Public Access
1
0

oauth working again (CORS allow all)

This commit is contained in:
Sander Roosendaal
2016-11-26 09:24:43 +01:00
parent 3ef5c40be4
commit 70f4a187ab
8 changed files with 603 additions and 37 deletions

View File

@@ -24,6 +24,11 @@ import numpy as np
from rowers import urls
from rowers.views import error500_view,error404_view,error400_view,error403_view
from dataprep import delete_strokedata
class DjangoTestCase(TestCase, MockTestCase):
def _pre_setup(self):
MockTestCase.setUp(self)
@@ -33,12 +38,12 @@ class DjangoTestCase(TestCase, MockTestCase):
def _post_teardown(self):
TestCase._post_teardown(self)
MockTestCase.tearDown(self)
delete_strokedata(1)
# Create your tests here.
class C2Objects(DjangoTestCase):
def test_strokedata(self):
print "C2 strokedata"
with open('rowers/testdata/c2stroketestdata.txt','r') as infile:
res = json.load(infile)
@@ -60,7 +65,6 @@ class C2Objects(DjangoTestCase):
class StravaObjects(DjangoTestCase):
def test_strokedata(self):
print "STRAVA strokedata"
timejson = json.load(open('rowers/testdata/stravatimetestdata.txt','r'))
velojson = json.load(open('rowers/testdata/stravavelotestdata.txt','r'))
distancejson = json.load(open('rowers/testdata/stravadistancetestdata.txt','r'))
@@ -136,7 +140,6 @@ class StravaObjects(DjangoTestCase):
class STObjects(DjangoTestCase):
def test_strokedata(self):
print "SportTracks strokedata"
with open('rowers/testdata/sporttrackstestdata.txt','r') as infile:
data = json.load(infile)
@@ -152,7 +155,6 @@ class STObjects(DjangoTestCase):
class TestErrorPages(TestCase):
def test_error_handlers(self):
print "Error Handlers"
self.assertTrue(urls.handler404.endswith('.error404_view'))
self.assertTrue(urls.handler500.endswith('.error500_view'))
@@ -178,7 +180,6 @@ class WorkoutTests(TestCase):
duration="0:55:00",distance=8000)
def test_checkworkoutuser(self):
print "Check Workout User"
u = User.objects.get(username='john')
r = Rower.objects.get(user=u)
w = Workout.objects.get(user=r)
@@ -198,7 +199,6 @@ class C2Tests(TestCase):
duration="0:55:00",distance=8000)
def c2_notokentest(self):
print "C2 No token"
thetoken = c2_open(self.u)
# should raise C2NoTokenError
self.assertRaises(C2NoTokenError)
@@ -213,7 +213,6 @@ class DataTest(TestCase):
def test_workoutform(self):
print "Workout Form"
form_data = {
'name':'test',
'date':'2016-05-01',
@@ -227,7 +226,6 @@ class DataTest(TestCase):
self.assertTrue(form.is_valid())
def test_rower_form_withvalidnumbers(self):
print "Workout Form with Valid Numbers"
form_data = {
'max':192,
'rest':48,
@@ -243,7 +241,6 @@ class DataTest(TestCase):
def test_rower_form_twoequalvalues(self):
print "Workout Form Error"
form_data = {
'max':192,
'rest':48,
@@ -258,7 +255,6 @@ class DataTest(TestCase):
self.assertFalse(form.is_valid())
def test_rower_form_abovemaxallowed(self):
print "Workout Form Error 2"
form_data = {
'max':300,
'rest':48,
@@ -273,7 +269,6 @@ class DataTest(TestCase):
self.assertFalse(form.is_valid())
def test_rower_form_wrongorder(self):
print "Workout form error 3"
form_data = {
'max':192,
'rest':48,
@@ -288,7 +283,6 @@ class DataTest(TestCase):
self.assertFalse(form.is_valid())
def test_rower_form_belowminalloed(self):
print "Workout form error 4"
form_data = {
'max':192,
'rest':2,
@@ -303,7 +297,6 @@ class DataTest(TestCase):
self.assertFalse(form.is_valid())
def test_rower_form_wrongorder2(self):
print "Workout form error 5"
form_data = {
'max':192,
'rest':48,
@@ -318,7 +311,6 @@ class DataTest(TestCase):
self.assertFalse(form.is_valid())
def test_painsled(self):
print "Test Painsled"
filename = 'C:\\python\\rowingdata\\testdata\\testdata.csv'
f = open(filename,'rb')
file_data = {'file': SimpleUploadedFile(f.name, f.read())}
@@ -399,7 +391,6 @@ class ViewTest(TestCase):
self.nu = datetime.datetime.now()
def test_upload_view_notloggedin(self):
print "Upload not logged in"
response = self.c.post('/rowers/workout/upload/',follow=True)
@@ -409,7 +400,6 @@ class ViewTest(TestCase):
self.assertEqual(response.status_code, 200)
def test_upload_view_sled(self):
print "Upload painsled"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\testdata.csv'
@@ -452,7 +442,6 @@ class ViewTest(TestCase):
def test_upload_view_notloggedin(self):
print "Upload not logged in"
response = self.c.post('/rowers/workout/upload/',follow=True)
@@ -462,7 +451,6 @@ class ViewTest(TestCase):
self.assertEqual(response.status_code, 200)
def test_upload_view_sled_negativetime(self):
print "Painsled error"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\tim.csv'
@@ -504,7 +492,6 @@ class ViewTest(TestCase):
def test_upload_view_sled_noname(self):
print "Upload no name"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\testdata.csv'
@@ -538,7 +525,6 @@ class ViewTest(TestCase):
def test_upload_view_TCX_CN(self):
print "Upload TCX"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\crewnerddata.tcx'
@@ -582,7 +568,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_TCX_SpeedCoach2(self):
print "Upload TCX 2"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\Speedcoach2example.csv'
@@ -613,7 +598,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_TCX_SpeedCoach2(self):
print "Upload TCX 3"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\Speedcoach2example.csv'
@@ -646,7 +630,6 @@ class ViewTest(TestCase):
def test_upload_view_TCX_SpeedCoach2(self):
print "Upload TCX 3"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\speedcoach3test3.csv'
@@ -677,7 +660,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_TCX_NoHR(self):
print "Upload TCX no HR"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\NoHR.tcx'
@@ -708,7 +690,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_TCX_CN(self):
print "Upload TCX 10"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\rowinginmotionexample.tcx'
@@ -736,7 +717,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_RP(self):
print "Upload RowPro"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\RP_testdata.csv'
@@ -764,7 +744,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_Mystery(self):
print "Upload Mystery"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\mystery.csv'
@@ -792,7 +771,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_RP_interval(self):
print "Upload RowPro Interval"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\RP_interval.csv'
@@ -820,7 +798,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_sled_desktop(self):
print "Upload Painsled Desktop"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\painsled_desktop_example.csv'
@@ -848,7 +825,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_sled_ergdata(self):
print "Upload Ergdata"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\ergdata_example.csv'
@@ -876,7 +852,6 @@ class ViewTest(TestCase):
os.remove(f_to_be_deleted)
def test_upload_view_sled_ergstick(self):
print "Upload Ergstick"
self.c.login(username='john',password='koeinsloot')
filename = 'C:\\python\\rowingdata\\testdata\\ergstick.csv'
@@ -953,7 +928,6 @@ class subroutinetests(TestCase):
def c2stuff(self):
print "Test C2 Stuff"
data = c2stuff.createc2workoutdata(self.w)
jsond = json.dumps(data)
data = c2stuff.createc2workoutdata_as_splits(w)
@@ -999,7 +973,6 @@ class PlotTests(TestCase):
def test_ote_plots(self):
print "Plots"
w = self.wote
f1 = 'testdata.csv'[:-4]
timestr = strftime("%Y%m%d-%H%M%S")
@@ -1107,7 +1080,6 @@ class PlotTests(TestCase):
os.remove(fullpathimagename)
def test_otw_plots(self):
print "Plots 2"
w = self.wotw
f1 = 'testdata.csv'[:-4]
timestr = strftime("%Y%m%d-%H%M%S")