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

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