Private
Public Access
1
0

more unit tests

This commit is contained in:
Sander Roosendaal
2021-01-11 17:43:18 +01:00
parent 82b5ece732
commit e153e63481
7 changed files with 1278 additions and 1 deletions

View File

@@ -236,7 +236,7 @@ def get_video_data(w,groups=['basic'],mode='water'):
metrics = collections.OrderedDict(sorted(metrics.items()))
maxtime = coordinates['time'].max()
return data, metrics, maxtime

View File

@@ -3476,6 +3476,7 @@ def interactive_agegroupcpchart(age,normalized=False):
def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data',
title='',type='water'):
powerdf = powerdf[~(powerdf == 0).any(axis=1)]
# plot tools
if (promember==1):
@@ -4136,6 +4137,7 @@ def interactive_streamchart(id=0,promember=0):
return [script,div]
def interactive_chart(id=0,promember=0,intervaldata = {}):
# Add hover to this comma-separated string and see what changes
if (promember==1):
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'

View File

@@ -1000,6 +1000,9 @@ class GoldMedalScores(TestCase):
self.c = Client()
self.user_workouts = WorkoutFactory.create_batch(20, user=self.r)
ws = Workout.objects.all().order_by('date')
ws[0].rankingpiece = True
ws[0].save()
self.factory = RequestFactory()
self.password = faker.word()
self.u.set_password(self.password)

View File

@@ -4,6 +4,7 @@ from __future__ import print_function
from __future__ import unicode_literals
from .statements import *
from rowers.mytypes import rowtypes
nu = datetime.datetime.now()
@@ -58,3 +59,43 @@ class InteractivePlotTests(TestCase):
script, div = interactiveplots.interactive_activitychart(workouts,startdate,enddate)
self.assertFalse(len(script)==0)
self.assertFalse(len(div)==0)
def test_interactive_otwcpchart(self):
df = pd.read_csv('rowers/tests/testdata/otwcp.csv')
script, div, p1, ratio, message = interactiveplots.interactive_otwcpchart(df,r=self.r,cpfit='data')
self.assertFalse(len(script)==0)
self.assertFalse(len(div)==0)
script, div, p1, ratio, message = interactiveplots.interactive_otwcpchart(df,r=self.r,cpfit='automatic')
self.assertFalse(len(script)==0)
self.assertFalse(len(div)==0)
def test_interactive_chart(self):
workout = Workout.objects.filter(user=self.r,workouttype__in=mytypes.rowtypes)[0]
id = workout.id
script, div = interactiveplots.interactive_chart(id=id)
self.assertFalse(len(script)==0)
self.assertFalse(len(div)==0)
intervaldata = {
'itime': [0.0, 234.0, 61.2, 59.7, 60.5, 61.0, 44.2, 74.7, 44.8, 75.1, 43.4, 78.0, 40.1, 79.4, 42.4, 76.1, 45.4, 75.2, 43.2, 255.0, 60.0, 60.6, 60.7, 60.7, 55.3, 65.4, 58.2, 60.2, 59.7, 62.0, 44.7, 72.5, 43.2, 78.5, 56.4, 889.5],
'idist': [0, 700, 257, 179, 254, 197, 185, 246, 190, 240, 181, 240, 169, 241, 179, 215, 180, 223, 179, 302, 247, 190, 246, 180, 229, 197, 242, 179, 245, 189, 175, 208, 166, 218, 224, 2399],
'itype': [4, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3, 4.0, 3],
'selector': 'power',
'normp': 203,
'normv': 3.557050625695544
}
script, div = interactiveplots.interactive_chart(id=id,intervaldata=intervaldata)
self.assertFalse(len(script)==0)
self.assertFalse(len(div)==0)
def test_interactive_chart_video(self):
datadf = pd.read_csv('rowers/tests/testdata/videodata.csv')
data = datadf.to_dict()
script, div = interactiveplots.interactive_chart_video(data)
self.assertFalse(len(script)==0)
self.assertFalse(len(div)==0)

36
rowers/tests/testdata/otwcp.csv vendored Normal file
View File

@@ -0,0 +1,36 @@
,Delta,CP,workout,url
0,6.0,340.1333334878639,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
1,7.0,338.96666679029113,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
2,8.0,338.71428568590255,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
3,10.0,339.43571423334737,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
4,11.0,339.80178561827967,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
5,12.0,339.2885803634247,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
6,15.0,338.8528139864973,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
7,17.0,337.4631313049432,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
8,20.0,337.8169515282718,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
9,24.0,335.4814812361949,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
10,30.0,330.284275590586,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
11,36.0,326.1298700713836,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
12,44.0,306.14423090749636,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
13,55.0,297.21960064902305,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
14,68.0,279.2818076545548,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
15,84.0,261.9537069142544,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
16,105.0,245.38402312135386,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
17,130.0,236.2756178973642,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
18,163.0,249.37083678010336,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
19,204.0,240.90711703539813,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
20,256.0,229.8622390192616,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
21,321.0,227.8746514703743,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
22,403.0,225.8329855924891,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
23,506.0,221.91079812206573,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
24,635.0,220.762340476955,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
25,799.0,212.73512266030042,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
26,1005.0,212.8565037482774,2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/4df830f9/
27,1263.0,139.9511726253205,2020-12-11 C2 Import Workout from 2020-12-11 10:06:06+00:00 11427m 01:00:08 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/db9b0a94/
28,1589.0,138.8309130746855,2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/16ffc190/
30,2000.0,137.5323799240252,2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/16ffc190/
32,2516.0,135.5675172186318,2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/16ffc190/
34,3167.0,134.68660138671376,2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/16ffc190/
36,3986.0,134.2073467308539,2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/16ffc190/
38,5016.0,133.822526821714,2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/16ffc190/
40,6314.0,133.7172039237248,2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal,http://localhost:8000/rowers/workout/16ffc190/
1 Delta CP workout url
2 0 6.0 340.1333334878639 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
3 1 7.0 338.96666679029113 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
4 2 8.0 338.71428568590255 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
5 3 10.0 339.43571423334737 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
6 4 11.0 339.80178561827967 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
7 5 12.0 339.2885803634247 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
8 6 15.0 338.8528139864973 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
9 7 17.0 337.4631313049432 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
10 8 20.0 337.8169515282718 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
11 9 24.0 335.4814812361949 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
12 10 30.0 330.284275590586 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
13 11 36.0 326.1298700713836 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
14 12 44.0 306.14423090749636 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
15 13 55.0 297.21960064902305 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
16 14 68.0 279.2818076545548 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
17 15 84.0 261.9537069142544 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
18 16 105.0 245.38402312135386 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
19 17 130.0 236.2756178973642 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
20 18 163.0 249.37083678010336 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
21 19 204.0 240.90711703539813 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
22 20 256.0 229.8622390192616 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
23 21 321.0 227.8746514703743 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
24 22 403.0 225.8329855924891 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
25 23 506.0 221.91079812206573 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
26 24 635.0 220.762340476955 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
27 25 799.0 212.73512266030042 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
28 26 1005.0 212.8565037482774 2020-12-31 Sprintervals 10106m 00:54:42 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/4df830f9/
29 27 1263.0 139.9511726253205 2020-12-11 C2 Import Workout from 2020-12-11 10:06:06+00:00 11427m 01:00:08 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/db9b0a94/
30 28 1589.0 138.8309130746855 2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/16ffc190/
31 30 2000.0 137.5323799240252 2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/16ffc190/
32 32 2516.0 135.5675172186318 2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/16ffc190/
33 34 3167.0 134.68660138671376 2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/16ffc190/
34 36 3986.0 134.2073467308539 2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/16ffc190/
35 38 5016.0 133.822526821714 2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/16ffc190/
36 40 6314.0 133.7172039237248 2020-11-23 Morning water 20314m 01:49:33 water 1x Sander Roosendaal http://localhost:8000/rowers/workout/16ffc190/

1194
rowers/tests/testdata/videodata.csv vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -309,3 +309,4 @@
309,604,failed_queue_empty,Other Apps views,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
310,605,failed_job_view,Other Apps views,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE,FALSE,
311,49,performancemanager_view,Performance Manager,TRUE,302,pro,200,302,pro,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
312,606,workout_flexchart_stacked_view,flex chart,TRUE,302,basic,200,403,basic,200,200,coach,200,200,FALSE,FALSE,TRUE,TRUE,TRUE,
1 id view function anonymous anonymous_response own own_response own_nonperm member member_response member_nonperm coachee coachee_response coachee_nonperm is_staff userid workoutid dotest realtest kwargs
309 309 604 failed_queue_empty Other Apps views TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
310 310 605 failed_job_view Other Apps views TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE TRUE FALSE FALSE
311 311 49 performancemanager_view Performance Manager TRUE 302 pro 200 302 pro 200 302 coach 200 302 FALSE FALSE FALSE TRUE TRUE
312 312 606 workout_flexchart_stacked_view flex chart TRUE 302 basic 200 403 basic 200 200 coach 200 200 FALSE FALSE TRUE TRUE TRUE