should pass tests now
This commit is contained in:
@@ -1572,7 +1572,6 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
if title is not None and len(title)>140:
|
||||
title = title[0:140]
|
||||
|
||||
|
||||
w = Workout(user=r, name=title, date=workoutdate,
|
||||
workouttype=workouttype,
|
||||
boattype=boattype,
|
||||
@@ -1813,6 +1812,7 @@ def new_workout_from_file(r, f2,
|
||||
workoutsource=None,
|
||||
title='Workout',
|
||||
boattype='1x',
|
||||
rpe=-1,
|
||||
makeprivate=False,
|
||||
notes='',
|
||||
uploadoptions={'boattype':'1x','workouttype':'rower'}):
|
||||
@@ -1947,6 +1947,7 @@ def new_workout_from_file(r, f2,
|
||||
dosummary=dosummary,
|
||||
workoutsource=workoutsource,
|
||||
summary=summary,
|
||||
rpe=rpe,
|
||||
inboard=inboard, oarlength=oarlength,
|
||||
title=title,
|
||||
forceunit='N',
|
||||
|
||||
@@ -245,17 +245,23 @@ class StandardsForm(forms.Form):
|
||||
|
||||
# The form used for uploading files
|
||||
class DocumentsForm(forms.Form):
|
||||
rpechoices = Workout.rpechoices
|
||||
rpechoices = tuple([(-1,'---')]+list(rpechoices))
|
||||
title = forms.CharField(required=False)
|
||||
file = forms.FileField(required=False,
|
||||
validators=[validate_file_extension])
|
||||
|
||||
workouttype = forms.ChoiceField(required=True,
|
||||
choices=Workout.workouttypes)
|
||||
choices=Workout.workouttypes,
|
||||
label='Workout Type')
|
||||
|
||||
boattype = forms.ChoiceField(required=True,
|
||||
choices=mytypes.boattypes,
|
||||
label = "Boat Type")
|
||||
|
||||
rpe = forms.ChoiceField(required=False,
|
||||
choices=rpechoices,
|
||||
label='Rate of Perceived Exertion',initial=-1)
|
||||
|
||||
notes = forms.CharField(required=False,
|
||||
widget=forms.Textarea)
|
||||
|
||||
@@ -195,6 +195,7 @@ class CPChartTest(TestCase):
|
||||
'duplicate': False,
|
||||
'avghr': '160',
|
||||
'avgpwr': 0,
|
||||
'rpe':4,
|
||||
'avgspm': 40,
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
#from __future__ import print_function
|
||||
from .statements import *
|
||||
from django.db import transaction
|
||||
|
||||
@override_settings(TESTING=True)
|
||||
class EmailUpload(TestCase):
|
||||
@@ -62,6 +63,7 @@ workout run
|
||||
'workouttype':'rower',
|
||||
'boattype': '1x',
|
||||
'notes': 'aap noot mies',
|
||||
'rpe':1,
|
||||
'make_plot': False,
|
||||
'upload_to_C2': False,
|
||||
'plottype': 'timeplot',
|
||||
@@ -84,27 +86,29 @@ workout run
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
@patch('rowers.dataprep.getsmallrowdata_db',side_effect=mocked_getsmallrowdata_db)
|
||||
def test_uploadapi2(self,mocked_sqlalchemy,mocked_getsmallrowdata_db):
|
||||
form_data = {
|
||||
'title': 'test',
|
||||
'workouttype':'rower',
|
||||
'boattype': '1x',
|
||||
'notes': 'aap noot mies',
|
||||
'make_plot': False,
|
||||
'upload_to_C2': False,
|
||||
'plottype': 'timeplot',
|
||||
'file': 'media/mailbox_attachments/colin3.csv',
|
||||
'secret': settings.UPLOAD_SERVICE_SECRET,
|
||||
'useremail': 'sander2@ds.nl',
|
||||
}
|
||||
with transaction.atomic():
|
||||
form_data = {
|
||||
'title': 'test',
|
||||
'workouttype':'rower',
|
||||
'boattype': '1x',
|
||||
'notes': 'aap noot mies',
|
||||
'make_plot': False,
|
||||
'upload_to_C2': False,
|
||||
'plottype': 'timeplot',
|
||||
'rpe':4,
|
||||
'file': 'media/mailbox_attachments/colin3.csv',
|
||||
'secret': settings.UPLOAD_SERVICE_SECRET,
|
||||
'useremail': 'sander2@ds.nl',
|
||||
}
|
||||
|
||||
url = reverse('workout_upload_api')
|
||||
response = self.c.post(url,form_data,HTTP_HOST='127.0.0.1:4533')
|
||||
self.assertEqual(response.status_code,200)
|
||||
url = reverse('workout_upload_api')
|
||||
response = self.c.post(url,form_data,HTTP_HOST='127.0.0.1:4533')
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
# should also test if workout is created
|
||||
w = Workout.objects.get(id=1)
|
||||
self.assertEqual(w.name,'test')
|
||||
self.assertEqual(w.notes,'aap noot mies')
|
||||
# should also test if workout is created
|
||||
w = Workout.objects.get(id=1)
|
||||
self.assertEqual(w.name,'test')
|
||||
self.assertEqual(w.notes,'aap noot mies')
|
||||
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
@patch('rowers.dataprep.getsmallrowdata_db',side_effect=mocked_getsmallrowdata_db)
|
||||
|
||||
@@ -32,6 +32,7 @@ class DataTest(TestCase):
|
||||
'weightcategory':'lwt',
|
||||
'adaptiveclass': 'PR1',
|
||||
'workouttype':'water',
|
||||
'rpe':1,
|
||||
'boattype':'1x',
|
||||
'private':False,
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ class ForceUnits(TestCase):
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'rpe': 1,
|
||||
'file': f,
|
||||
}
|
||||
|
||||
@@ -100,6 +101,7 @@ class ForceUnits(TestCase):
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'make_plot':False,
|
||||
'rpe': 1,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
@@ -131,6 +133,7 @@ class ForceUnits(TestCase):
|
||||
file_data = {'file': f}
|
||||
form_data = {
|
||||
'title':'test',
|
||||
'rpe':1,
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
|
||||
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||
#from __future__ import print_function
|
||||
from .statements import *
|
||||
nu = datetime.datetime.now()
|
||||
from django.db import transaction
|
||||
|
||||
from rowers.views import add_defaultfavorites
|
||||
|
||||
@@ -50,7 +51,9 @@ class ViewTest(TestCase):
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'rpe':4,
|
||||
'make_plot':False,
|
||||
'rpe':6,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
@@ -100,6 +103,7 @@ class ViewTest(TestCase):
|
||||
'adaptiveclass':'PR1',
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'rpe':4,
|
||||
'dragfactor':'112',
|
||||
'private':True,
|
||||
'notes':'noot mies',
|
||||
@@ -141,6 +145,7 @@ class ViewTest(TestCase):
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'rpe':6,
|
||||
'make_plot':False,
|
||||
'upload_to_C2':False,
|
||||
'upload_to_Strava':False,
|
||||
@@ -193,6 +198,7 @@ class ViewTest(TestCase):
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
'rpe':6,
|
||||
}
|
||||
|
||||
form = DocumentsForm(form_data,file_data)
|
||||
@@ -229,6 +235,7 @@ class ViewTest(TestCase):
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
'rpe':6,
|
||||
}
|
||||
|
||||
form = DocumentsForm(form_data,file_data)
|
||||
@@ -263,6 +270,7 @@ class ViewTest(TestCase):
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
'rpe':6,
|
||||
}
|
||||
|
||||
form = DocumentsForm(form_data,file_data)
|
||||
@@ -313,6 +321,7 @@ class ViewTest(TestCase):
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
'rpe':6,
|
||||
}
|
||||
|
||||
form = DocumentsForm(form_data,file_data)
|
||||
@@ -350,6 +359,7 @@ class ViewTest(TestCase):
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
'rpe':6,
|
||||
}
|
||||
|
||||
form = DocumentsForm(form_data,file_data)
|
||||
@@ -389,6 +399,7 @@ class ViewTest(TestCase):
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
'rpe':6,
|
||||
}
|
||||
|
||||
form = DocumentsForm(form_data,file_data)
|
||||
@@ -424,6 +435,7 @@ class ViewTest(TestCase):
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'rpe':1,
|
||||
'file': f,
|
||||
}
|
||||
|
||||
@@ -459,6 +471,7 @@ class ViewTest(TestCase):
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'make_plot':False,
|
||||
'rpe':1,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
@@ -531,6 +544,7 @@ class ViewTest(TestCase):
|
||||
file_data = {'file': f}
|
||||
form_data = {
|
||||
'title':'test',
|
||||
'rpe':1,
|
||||
'workouttype':'water',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
@@ -570,6 +584,7 @@ class ViewTest(TestCase):
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'rpe':4,
|
||||
'file': f,
|
||||
}
|
||||
|
||||
@@ -623,35 +638,37 @@ class ViewTest(TestCase):
|
||||
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
def test_upload_view_RP_interval(self, mocked_sqlalchemy):
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
with transaction.atomic():
|
||||
self.c.login(username='john',password='koeinsloot')
|
||||
|
||||
filename = 'rowers/tests/testdata/RP_interval.csv'
|
||||
f = open(filename,'rb')
|
||||
file_data = {'file': f}
|
||||
form_data = {
|
||||
'title':'test',
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
}
|
||||
filename = 'rowers/tests/testdata/RP_interval.csv'
|
||||
f = open(filename,'rb')
|
||||
file_data = {'file': f}
|
||||
form_data = {
|
||||
'title':'test',
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'rpe':1,
|
||||
'file': f,
|
||||
}
|
||||
|
||||
form = DocumentsForm(form_data,file_data)
|
||||
form = DocumentsForm(form_data,file_data)
|
||||
|
||||
response = self.c.post('/rowers/workout/upload/', form_data, follow=True)
|
||||
self.assertRedirects(response, expected_url='/rowers/workout/'+encoded1+'/edit/',
|
||||
response = self.c.post('/rowers/workout/upload/', form_data, follow=True)
|
||||
self.assertRedirects(response, expected_url='/rowers/workout/'+encoded1+'/edit/',
|
||||
status_code=302,target_status_code=200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except (FileNotFoundError,OSError):
|
||||
pass
|
||||
w = Workout.objects.get(id=1)
|
||||
f_to_be_deleted = w.csvfilename
|
||||
try:
|
||||
os.remove(f_to_be_deleted+'.gz')
|
||||
except (FileNotFoundError,OSError):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -667,6 +684,7 @@ class ViewTest(TestCase):
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'rpe':4,
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
@@ -699,6 +717,7 @@ class ViewTest(TestCase):
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'rpe':4,
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
@@ -731,6 +750,7 @@ class ViewTest(TestCase):
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'rpe':4,
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
@@ -762,6 +782,7 @@ class ViewTest(TestCase):
|
||||
'title':'test',
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'rpe':4,
|
||||
'notes':'aap noot mies',
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
|
||||
@@ -10,7 +10,9 @@ nu = datetime.datetime.now()
|
||||
|
||||
|
||||
tested = [
|
||||
'/rowers/me/delete/'
|
||||
'/rowers/me/delete/',
|
||||
'/rowers/performancemanager/'
|
||||
|
||||
]
|
||||
|
||||
#@pytest.mark.django_db
|
||||
@@ -76,7 +78,7 @@ class URLTests(TestCase):
|
||||
'/rowers/agegroupcp/30/1/',
|
||||
'/rowers/agegrouprecords/male/hwt/',
|
||||
'/rowers/agegrouprecords/male/hwt/2000m/',
|
||||
'/rowers/agegrouprecords/male/hwt/2000min/',
|
||||
'/rowers/agegrouprecords/male/hwt/30min/',
|
||||
'/rowers/ajax_agegroup/45/hwt/male/1/',
|
||||
'/rowers/analysis/',
|
||||
'/rowers/analysis/user/1/',
|
||||
@@ -240,6 +242,8 @@ class URLTests(TestCase):
|
||||
# '/rowers/workouts-join-select/2016-01-01/2016-12-31/',
|
||||
]
|
||||
|
||||
|
||||
|
||||
# urlstotest = ['/rowers/createplan/user/1/']
|
||||
|
||||
lijst = []
|
||||
|
||||
@@ -585,8 +585,11 @@ def addmanual_view(request,raceid=0):
|
||||
weightcategory = form.cleaned_data['weightcategory']
|
||||
adaptiveclass = form.cleaned_data['adaptiveclass']
|
||||
distance = form.cleaned_data['distance']
|
||||
rpe = form.cleaned_data['rpe']
|
||||
if not rpe:
|
||||
try:
|
||||
rpe = form.cleaned_data['rpe']
|
||||
if not rpe:
|
||||
rpe = -1
|
||||
except KeyError:
|
||||
rpe = -1
|
||||
notes = form.cleaned_data['notes']
|
||||
thetimezone = form.cleaned_data['timezone']
|
||||
@@ -4361,8 +4364,11 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
notes = form.cleaned_data['notes']
|
||||
newdragfactor = form.cleaned_data['dragfactor']
|
||||
thetimezone = form.cleaned_data['timezone']
|
||||
rpe = form.cleaned_data['rpe']
|
||||
if not rpe:
|
||||
try:
|
||||
rpe = form.cleaned_data['rpe']
|
||||
if not rpe:
|
||||
rpe = -1
|
||||
except KeyError:
|
||||
rpe = -1
|
||||
|
||||
try:
|
||||
@@ -4874,6 +4880,10 @@ def workout_upload_api(request):
|
||||
t = form.cleaned_data['title']
|
||||
boattype = form.cleaned_data['boattype']
|
||||
workouttype = form.cleaned_data['workouttype']
|
||||
try:
|
||||
rpe = form.cleaned_data['rpe']
|
||||
except KeyError:
|
||||
rpe = -1
|
||||
if rowerform.is_valid():
|
||||
u = rowerform.cleaned_data['user']
|
||||
r = getrower(u)
|
||||
@@ -4929,6 +4939,7 @@ def workout_upload_api(request):
|
||||
boattype=boattype,
|
||||
makeprivate=makeprivate,
|
||||
title = t,
|
||||
rpe=rpe,
|
||||
notes=notes,
|
||||
uploadoptions=post_data,
|
||||
)
|
||||
@@ -5049,6 +5060,13 @@ def workout_upload_view(request,
|
||||
except KeyError:
|
||||
boattype = '1x'
|
||||
|
||||
try:
|
||||
rpe = docformoptions['rpe']
|
||||
if not rpe:
|
||||
rpe = -1
|
||||
except KeyError:
|
||||
rpe = -1
|
||||
|
||||
try:
|
||||
notes = docformoptions['notes']
|
||||
except KeyError:
|
||||
@@ -5126,6 +5144,10 @@ def workout_upload_view(request,
|
||||
t = form.cleaned_data['title']
|
||||
workouttype = form.cleaned_data['workouttype']
|
||||
boattype = form.cleaned_data['boattype']
|
||||
try:
|
||||
rpe = form.cleaned_data['rpe']
|
||||
except KeyError:
|
||||
rpe = -1
|
||||
|
||||
request.session['docformoptions'] = {
|
||||
'workouttype':workouttype,
|
||||
@@ -5166,6 +5188,7 @@ def workout_upload_view(request,
|
||||
'upload_to_TrainingPeaks':upload_to_tp,
|
||||
'landingpage':landingpage,
|
||||
'boattype': boattype,
|
||||
'rpe':rpe,
|
||||
'workouttype': workouttype,
|
||||
}
|
||||
|
||||
@@ -5181,6 +5204,7 @@ def workout_upload_view(request,
|
||||
workouttype=workouttype,
|
||||
workoutsource=workoutsource,
|
||||
boattype=boattype,
|
||||
rpe=rpe,
|
||||
makeprivate=makeprivate,
|
||||
title = t,
|
||||
notes=notes,
|
||||
|
||||
Reference in New Issue
Block a user