Private
Public Access
1
0

adding tests

This commit is contained in:
Sander Roosendaal
2021-04-19 18:51:41 +02:00
parent c494fdca2c
commit 33fcc321c1
3 changed files with 115 additions and 18 deletions

View File

@@ -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
View 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: ""