going through importviews ... coverage
This commit is contained in:
@@ -1442,6 +1442,104 @@ class PlannedSessionsView(TestCase):
|
||||
added = plannedsessions.add_team_session(self.team,self.ps_trimp)
|
||||
self.ps_trimp.save()
|
||||
|
||||
s = b"""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: ""
|
||||
"""
|
||||
|
||||
self.file_data = {'yaml': SimpleUploadedFile('britishrowing.yml', s)}
|
||||
|
||||
with open('media/temp.yml','wb') as f:
|
||||
f.write(s)
|
||||
|
||||
self.instantplan = InstantPlan(
|
||||
uuid = "79b0dacf-9b49-4f33-9acf-e2e6734e22dc",
|
||||
url = "https://thepeteplan.wordpress.com/beginner-training/",
|
||||
name = faker.word(),
|
||||
goal = faker.word(),
|
||||
duration = 42,
|
||||
description = faker.word(),
|
||||
target = faker.word(),
|
||||
hoursperweek = 3,
|
||||
sessionsperweek = 3,
|
||||
price = 0,
|
||||
yaml = 'temp.yml',
|
||||
)
|
||||
|
||||
self.instantplan.save()
|
||||
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
@@ -1555,6 +1653,29 @@ class PlannedSessionsView(TestCase):
|
||||
response = self.c.post(url,formdata,follow=True)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
def test_deletetarget_view(self):
|
||||
login = self.c.login(username=self.u.username, password=self.password)
|
||||
self.assertTrue(login)
|
||||
|
||||
url = reverse('rower_delete_trainingtarget',kwargs={'id':self.target.id})
|
||||
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,302)
|
||||
|
||||
def test_deletetrainingplan_view(self):
|
||||
login = self.c.login(username=self.u.username, password=self.password)
|
||||
self.assertTrue(login)
|
||||
|
||||
url = reverse('trainingplan_delete_view',kwargs={'pk':self.plan.id})
|
||||
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
form = {}
|
||||
response = self.c.post(url,form)
|
||||
self.assertEqual(response.status_code,302)
|
||||
|
||||
|
||||
|
||||
def test_multicreate_view(self):
|
||||
login = self.c.login(username=self.u.username, password=self.password)
|
||||
@@ -1637,6 +1758,10 @@ class PlannedSessionsView(TestCase):
|
||||
response = self.c.post(url,form_data,follow=True)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
url = reverse('remove_groupsession_view',kwargs={'id':self.ps_trimp.id})
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,302)
|
||||
|
||||
|
||||
def test_teamedit_view(self):
|
||||
login = self.c.login(username=self.u.username, password=self.password)
|
||||
@@ -1908,86 +2033,29 @@ class PlannedSessionsView(TestCase):
|
||||
#'yaml': {'yaml': SimpleUploadedFile('britishrowing.yml', f.read())}
|
||||
}
|
||||
|
||||
s = b"""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: ""
|
||||
"""
|
||||
|
||||
file_data = {'yaml': SimpleUploadedFile('britishrowing.yml', s)}
|
||||
|
||||
form = InstantPlanForm(form_data,file_data)
|
||||
form = InstantPlanForm(form_data,self.file_data)
|
||||
if not form.is_valid():
|
||||
print(form.errors)
|
||||
self.assertTrue(form.is_valid())
|
||||
|
||||
# look at a instant plan
|
||||
url = reverse('rower_view_instantplan',kwargs={'id':self.instantplan.uuid})
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
form_data = {
|
||||
'name':faker.word(),
|
||||
'target': '',
|
||||
'startdate':datetime.datetime.now().strftime('%Y-%m-%d'),
|
||||
'enddate':(datetime.datetime.now()+datetime.timedelta(days=self.instantplan.duration)).strftime('%Y-%m-%d'),
|
||||
'notes': faker.word(),
|
||||
'datechoice':'startdate',
|
||||
}
|
||||
|
||||
form = InstantPlanSelectForm(form_data)
|
||||
self.assertTrue(form.is_valid())
|
||||
|
||||
response = self.c.post(url,form_data,follow=True)
|
||||
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
Reference in New Issue
Block a user