Private
Public Access
1
0

further coverage increases

This commit is contained in:
Sander Roosendaal
2021-04-13 19:20:04 +02:00
parent 08dbd43b61
commit 9c6cf18ee5
8 changed files with 208 additions and 205 deletions

View File

@@ -5,7 +5,7 @@ pytestmark = pytest.mark.django_db
from bs4 import BeautifulSoup
import re
from nose_parameterized import parameterized
from parameterized import parameterized
from django.test import TestCase, Client,override_settings
from django.core.management import call_command
from django.utils.six import StringIO
@@ -62,7 +62,7 @@ class AjaxTests(TestCase):
starttime=self.nu.strftime('%H:%M:%S'),
duration="0:55:00",distance=8000,
csvfilename=self.filename)
self.wote = Workout.objects.create(name='testworkout',
workouttype='Indoor Rower',
user=r,date=self.nu.strftime('%Y-%m-%d'),
@@ -72,7 +72,7 @@ class AjaxTests(TestCase):
self.c = Client()
def test_toggle_ranking(self):
response = self.c.get(
'/rowers/workout/1/toggle-ranking/',

View File

@@ -13,7 +13,7 @@ encoded13 = str(encoder.encode_hex(13))
from bs4 import BeautifulSoup
import re
from nose_parameterized import parameterized
from parameterized import parameterized
from django.test import TestCase, Client,override_settings
from django.core.management import call_command
from django.utils.six import StringIO

View File

@@ -308,6 +308,25 @@ class WorkoutViewTest(TestCase):
response = self.c.get(url,follow=True)
self.assertEqual(response.status_code,200)
# Stacked Flex Chart
url = reverse('workout_flexchart_stacked_view',kwargs={
'id': encoder.encode_hex(self.wwater.id),
})
response = self.c.get(url,follow=True)
self.assertEqual(response.status_code,200)
form_data = {
'xparam':'distance',
'yparam1':'power',
'yparam2':'driveenergy',
'yparam3':'hr',
'yparam4':'strokedistance'
}
response = self.c.post(url,form_data)
self.assertEqual(response.status_code,200)
url = reverse('workout_erase_column_view',kwargs={'id':encoder.encode_hex(self.wwater.id),'column':'hr'})
expected_url = reverse('workout_data_view',kwargs={'id':encoder.encode_hex(self.wwater.id)})
@@ -323,7 +342,7 @@ class WorkoutViewTest(TestCase):
'cols':['driveenergy','spm']
}
form = DataFrameColumnsForm(form_data)
self.assertTrue(form.is_valid())
response = self.c.post(url,form_data)

View File

@@ -45,6 +45,13 @@ workout run
copy('rowers/tests/testdata/emails/colin.csv',a2)
a3 = 'media/mailbox_attachments/colin4.csv'
copy('rowers/tests/testdata/emails/colin.csv',a3)
a4 = 'media/mailbox_attachments/colin5.csv'
copy('rowers/tests/testdata/emails/colin.csv',a4)
a5 = 'media/mailbox_attachments/colin6.csv'
copy('rowers/tests/testdata/emails/colin.csv',a5)
a6 = 'media/mailbox_attachments/colin7.csv'
copy('rowers/tests/testdata/emails/colin.csv',a6)
a = MessageAttachment(message=m,document=a2[6:])
a.save()
@@ -88,6 +95,29 @@ workout run
self.assertEqual(w.name,'test')
self.assertEqual(w.notes,'aap noot mies')
# test exceptions
secret = form_data.pop('secret')
form_data['file'] = 'media/mailbox_attachments/colin5.csv'
response = self.c.post(url,form_data,HTTP_HOST='127.0.0.1:4533')
self.assertEqual(response.status_code,400)
form_data['secret'] = 'wrong'
form_data['file'] = 'media/mailbox_attachments/colin6.csv'
response = self.c.post(url,form_data,HTTP_HOST='127.0.0.1:4533')
self.assertEqual(response.status_code,403)
form_data['secret'] = secret
filename = form_data.pop('file')
response = self.c.post(url,form_data,HTTP_HOST='127.0.0.1:4533')
self.assertEqual(response.status_code,400)
form_data['file'] = filename
os.remove(filename)
response = self.c.post(url,form_data,HTTP_HOST='127.0.0.1:4533')
self.assertEqual(response.status_code,400)
@patch('rowers.dataprep.create_engine')

View File

@@ -56,10 +56,18 @@ class ViewTest(TestCase):
'rpe':6,
'upload_to_c2':False,
'plottype':'timeplot',
'landingpage':'workout_edit_view',
'raceid':0,
'file': f,
}
request = RequestFactory()
request.user = self.u
form = DocumentsForm(form_data,file_data)
optionsform = UploadOptionsForm(form_data,request=request)
self.assertTrue(optionsform.is_valid())
response = self.c.post('/rowers/workout/upload/', form_data, follow=True)
self.assertRedirects(response, expected_url='/rowers/workout/'+encoded1+'/edit/',
@@ -105,6 +113,8 @@ class ViewTest(TestCase):
'boattype':'1x',
'rpe':4,
'dragfactor':'112',
'raceid':0,
'landingpage':'workout_edit_view',
'private':True,
'notes':'noot mies',
}
@@ -153,6 +163,8 @@ class ViewTest(TestCase):
'upload_to_RunKeeper':False,
'upload_to_MapMyFitness':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
'makeprivate':False,
'landingpage':'workout_edit_view',
@@ -197,6 +209,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
'rpe':6,
}
@@ -234,6 +248,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
'rpe':6,
}
@@ -269,6 +285,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
'rpe':6,
}
@@ -320,6 +338,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
'rpe':6,
}
@@ -358,6 +378,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
'rpe':6,
}
@@ -396,6 +418,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
'rpe':6,
}
@@ -450,6 +474,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
'rpe':6,
}
@@ -487,6 +513,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'rpe':1,
'file': f,
}
@@ -525,6 +553,8 @@ class ViewTest(TestCase):
'make_plot':False,
'rpe':1,
'upload_to_c2':False,
'raceid':0,
'landingpage':'workout_edit_view',
'plottype':'timeplot',
'file': f,
}
@@ -564,6 +594,8 @@ class ViewTest(TestCase):
'notes':'aap noot mies',
'make_plot':False,
'upload_to_c2':False,
'raceid':0,
'landingpage':'workout_edit_view',
'plottype':'timeplot',
'file': f,
}
@@ -602,6 +634,8 @@ class ViewTest(TestCase):
'notes':'aap noot mies',
'make_plot':False,
'upload_to_c2':False,
'raceid':0,
'landingpage':'workout_edit_view',
'plottype':'timeplot',
'file': f,
}
@@ -636,6 +670,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'rpe':4,
'file': f,
}
@@ -670,6 +706,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
}
@@ -704,6 +742,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'rpe':1,
'file': f,
}
@@ -740,6 +780,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
}
@@ -773,6 +815,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
}
@@ -806,6 +850,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
}
@@ -839,6 +885,8 @@ class ViewTest(TestCase):
'make_plot':False,
'upload_to_c2':False,
'plottype':'timeplot',
'raceid':0,
'landingpage':'workout_edit_view',
'file': f,
}