Private
Public Access
1
0

should pass tests now

This commit is contained in:
Sander Roosendaal
2020-12-02 18:47:17 +01:00
parent 78c6bfb345
commit edb080f9b2
9 changed files with 116 additions and 51 deletions

View File

@@ -195,6 +195,7 @@ class CPChartTest(TestCase):
'duplicate': False,
'avghr': '160',
'avgpwr': 0,
'rpe':4,
'avgspm': 40,
}

View File

@@ -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)

View File

@@ -32,6 +32,7 @@ class DataTest(TestCase):
'weightcategory':'lwt',
'adaptiveclass': 'PR1',
'workouttype':'water',
'rpe':1,
'boattype':'1x',
'private':False,
}

View File

@@ -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',

View File

@@ -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,

View File

@@ -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 = []