adding tests
This commit is contained in:
@@ -195,6 +195,9 @@ class SessionTemplateTest(TestCase):
|
||||
|
||||
self.c = Client()
|
||||
self.user_workouts = WorkoutFactory.create_batch(5, user=self.r)
|
||||
for w in self.user_workouts:
|
||||
w.startdatetime = arrow.get(w.date).datetime
|
||||
|
||||
self.factory = RequestFactory()
|
||||
self.password = faker.word()
|
||||
self.u.set_password(self.password)
|
||||
@@ -276,6 +279,15 @@ class SessionTemplateTest(TestCase):
|
||||
response = self.c.get(url,follow=True)
|
||||
self.assertRedirects(response,expected_url=expected_url,status_code=302,target_status_code=200)
|
||||
|
||||
url = reverse('plannedsession_templateedit_view',kwargs={'id':t.id})
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
post_data['name'] = faker.word()
|
||||
|
||||
response = self.c.post(url,post_data,follow=True)
|
||||
self.assertRedirects(response,expected_url=expected_url,status_code=302,target_status_code=200)
|
||||
|
||||
@override_settings(TESTING=True)
|
||||
class SessionLinkTest(TestCase):
|
||||
def setUp(self):
|
||||
@@ -296,7 +308,7 @@ class SessionLinkTest(TestCase):
|
||||
self.pss = []
|
||||
|
||||
for w in self.user_workouts:
|
||||
startdatetime = w.startdatetime
|
||||
startdatetime = arrow.get(w.date).datetime
|
||||
|
||||
startdate = (startdatetime-datetime.timedelta(days=1)).date()
|
||||
enddate = (startdatetime+datetime.timedelta(days=1)).date()
|
||||
@@ -334,11 +346,12 @@ class SessionLinkTest(TestCase):
|
||||
|
||||
|
||||
w = self.user_workouts[0]
|
||||
startdatetime = w.startdatetime
|
||||
startdatetime = arrow.get(w.date).datetime
|
||||
|
||||
startdate = (startdatetime-datetime.timedelta(days=1)).date()
|
||||
enddate = (startdatetime+datetime.timedelta(days=1)).date()
|
||||
|
||||
|
||||
url = '/rowers/sessions/'
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
@@ -379,8 +392,6 @@ class SessionLinkTest(TestCase):
|
||||
enddate = enddate.strftime("%Y-%m-%d"),
|
||||
)
|
||||
|
||||
|
||||
|
||||
workoutdata = {}
|
||||
workoutdata['initial'] = []
|
||||
|
||||
@@ -391,6 +402,7 @@ class SessionLinkTest(TestCase):
|
||||
|
||||
workoutdata['choices'] = tuple(choices)
|
||||
|
||||
|
||||
form = PlannedSessionSelectForm(plannedsessionstuple,post_data)
|
||||
|
||||
self.assertTrue(form.is_valid())
|
||||
@@ -1430,6 +1442,8 @@ class PlannedSessionsView(TestCase):
|
||||
added = plannedsessions.add_team_session(self.team,self.ps_trimp)
|
||||
self.ps_trimp.save()
|
||||
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
os.remove(self.w1.csvfilename)
|
||||
@@ -1861,3 +1875,11 @@ class PlannedSessionsView(TestCase):
|
||||
|
||||
response = self.c.post(url,follow=True)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
def test_instantplan_vie(self):
|
||||
login = self.c.login(username=self.u.username, password=self.password)
|
||||
self.assertTrue(login)
|
||||
|
||||
url = reverse('rower_select_instantplan')
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
75
rowers/tests/testdata/britishrowing.yml
vendored
Normal file
75
rowers/tests/testdata/britishrowing.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
filename: britishrowing.json
|
||||
name: British Rowing Training Plan Beginner Week 1
|
||||
trainingDays:
|
||||
- order: 1
|
||||
workouts:
|
||||
- workoutName: Week 1 Session 1
|
||||
steps:
|
||||
- stepId: 0
|
||||
wkt_step_name: Warmup
|
||||
durationType: Time
|
||||
durationValue: 300000
|
||||
intensity: Warmup
|
||||
description: ""
|
||||
- stepId: 1
|
||||
wkt_step_name: Intervals
|
||||
durationType: Time
|
||||
durationValue: 60000
|
||||
intensity: Active
|
||||
description: ""
|
||||
- stepId: 2
|
||||
wkt_step_name: Interval Rest
|
||||
durationType: Time
|
||||
durationValue: 60000
|
||||
intensity: Rest
|
||||
description: ""
|
||||
- stepId: 3
|
||||
wkt_step_name: Rep
|
||||
durationType: RepeatUntilStepsCmplt
|
||||
durationValue: 1
|
||||
targetValue: 5
|
||||
- stepId: 4
|
||||
wkt_step_name: Cooldown
|
||||
durationType: Time
|
||||
durationValue: 300000
|
||||
intensity: Cooldown
|
||||
description: ""
|
||||
sport: ""
|
||||
description: ""
|
||||
- order: 4
|
||||
workouts:
|
||||
- workoutName: Week 1 Session 2
|
||||
steps:
|
||||
- stepId: 0
|
||||
wkt_step_name: Warmup
|
||||
durationType: Time
|
||||
durationValue: 300000
|
||||
intensity: Warmup
|
||||
description: ""
|
||||
- stepId: 1
|
||||
wkt_step_name: Interval
|
||||
durationType: Time
|
||||
durationValue: 300000
|
||||
intensity: Active
|
||||
description: ""
|
||||
- stepId: 2
|
||||
wkt_step_name: Interval Rest
|
||||
durationType: Time
|
||||
durationValue: 180000
|
||||
intensity: Rest
|
||||
description: ""
|
||||
- stepId: 3
|
||||
wkt_step_name: Rep
|
||||
durationType: RepeatUntilStepsCmplt
|
||||
durationValue: 1
|
||||
targetValue: 5
|
||||
- stepId: 4
|
||||
wkt_step_name: Cooldown
|
||||
durationType: Time
|
||||
durationValue: 300000
|
||||
intensity: Cooldown
|
||||
description: ""
|
||||
sport: ""
|
||||
description: ""
|
||||
duration: 7
|
||||
description: ""
|
||||
@@ -1305,7 +1305,7 @@ def plannedsessions_coach_view(request,
|
||||
for ps in sps:
|
||||
if 'coach' in request.user.rower.rowerplan:
|
||||
rowers += ps.rower.all().exclude(rowerplan='freecoach')
|
||||
else:
|
||||
else: # pragma: no cover
|
||||
rowers += ps.rower.filter(team__in=rteams).exclude(rowerplan='freecoach')
|
||||
|
||||
rowers = list(set(rowers))
|
||||
@@ -1805,10 +1805,10 @@ def plannedsession_teamclone_view(request,id=0):
|
||||
r = getrequestplanrower(request)
|
||||
|
||||
teams = Team.objects.filter(manager=request.user)
|
||||
if teams.count()>0:
|
||||
if teams.count()>0: # pragma: no cover
|
||||
teamchoices = [(team.id, team.name) for team in teams]
|
||||
teaminitial = [str(teams[0].id)]
|
||||
else:
|
||||
else: # pragma: no cover
|
||||
messages.info(request,"You have no teams established yet. We are redirecting you to the Team Management page.")
|
||||
url = reverse('rower_teams_view')
|
||||
return HttpResponseRedirect(url)
|
||||
@@ -1873,16 +1873,16 @@ def plannedsession_templateedit_view(request,id=0):
|
||||
|
||||
try:
|
||||
ps = PlannedSession.objects.get(id=id)
|
||||
except PlannedSession.DoesNotExist:
|
||||
except PlannedSession.DoesNotExist: # pragma: no cover
|
||||
raise Http404("Planned Session does not exist")
|
||||
|
||||
if ps.manager != request.user:
|
||||
if ps.manager != request.user: # pragma: no cover
|
||||
raise PermissionDenied("You are not allowed to edit this planned session")
|
||||
|
||||
if ps.sessiontype in ['race','indoorrace']:
|
||||
if ps.sessiontype in ['race','indoorrace']: # pragma: no cover
|
||||
raise PermissionDenied("You are not allowed to edit this planned session because it is a race")
|
||||
|
||||
if not ps.is_template:
|
||||
if not ps.is_template: # pragma: no cover
|
||||
ps.pk = None
|
||||
ps.id = None
|
||||
ps.is_template = True
|
||||
@@ -1900,7 +1900,7 @@ def plannedsession_templateedit_view(request,id=0):
|
||||
cd = sessioncreateform.cleaned_data
|
||||
if cd['sessionunit'] == 'min':
|
||||
cd['sessionmode'] = 'time'
|
||||
elif cd['sessionunit'] in ['km','m']:
|
||||
elif cd['sessionunit'] in ['km','m']: # pragma: no cover
|
||||
cd['sessionmode'] = 'distance'
|
||||
|
||||
obj = sessioncreateform.save(commit=False)
|
||||
@@ -1912,12 +1912,12 @@ def plannedsession_templateedit_view(request,id=0):
|
||||
|
||||
if res:
|
||||
messages.info(request,message)
|
||||
else:
|
||||
else: # pragma: no cover
|
||||
messages.error(request,message)
|
||||
|
||||
url = reverse('template_library_view')
|
||||
|
||||
if '_continue' in request.POST:
|
||||
if '_continue' in request.POST: # pragma: no cover
|
||||
url = reverse('plannedsession_templateedit_view',kwargs={
|
||||
'id':ps.id,
|
||||
})
|
||||
@@ -2030,7 +2030,7 @@ def plannedsession_edit_view(request,id=0,userid=0):
|
||||
if sessioncreateform.is_valid():
|
||||
cd = sessioncreateform.cleaned_data
|
||||
|
||||
if cd['sessionunit'] == 'min':
|
||||
if cd['sessionunit'] == 'min': # pragma: no cover
|
||||
cd['sessionmode'] = 'time'
|
||||
elif cd['sessionunit'] in ['km','m']:
|
||||
cd['sessionmode'] = 'distance'
|
||||
@@ -2041,12 +2041,12 @@ def plannedsession_edit_view(request,id=0,userid=0):
|
||||
|
||||
if res:
|
||||
messages.info(request,message)
|
||||
else:
|
||||
else: # pragma: no cover
|
||||
messages.error(request,message)
|
||||
|
||||
url = reverse('plannedsessions_view')
|
||||
|
||||
if "_continue" in request.POST:
|
||||
if "_continue" in request.POST: # pragma: no cover
|
||||
url = reverse(plannedsession_edit_view,
|
||||
kwargs={
|
||||
'id':int(ps.id),
|
||||
@@ -2256,7 +2256,7 @@ def plannedsession_view(request,id=0,userid=0):
|
||||
wdict['distance'] = ps.course.distance
|
||||
wdict['coursecompleted'] = False
|
||||
ranking.append(wdict)
|
||||
if ps.sessiontype == 'coursetest':
|
||||
if ps.sessiontype == 'coursetest': # pragma: no cover
|
||||
ranking = sorted(ranking, key=lambda k: k['time'])
|
||||
|
||||
if ps.sessiontype == 'fastest_distance': # pragma: no cover
|
||||
|
||||
Reference in New Issue
Block a user