Private
Public Access
1
0

passing tests - teams can be created

This commit is contained in:
Sander Roosendaal
2019-02-15 21:11:00 +01:00
parent 9bb7c3bef2
commit 948fbf76ee
7 changed files with 120 additions and 60 deletions

View File

@@ -112,7 +112,7 @@ class PermissionsBasicsTests(TestCase):
## Low level
## Coach can have any number of groups
def test_plan_groupmanager(self):
def test_coach_groupmanager(self):
team1 = Team.objects.create(
name = 'FirstTeam',
notes = faker.text(),
@@ -131,7 +131,7 @@ class PermissionsBasicsTests(TestCase):
team3 = Team.objects.create(
name = 'SecondTeam',
name = 'ThirdTeam',
notes = faker.text(),
manager = self.ucoach,
)
@@ -447,8 +447,6 @@ class PermissionsViewTests(TestCase):
'name': faker.word(),
}
print 'posting to sessions/create'
form = PlannedSessionForm(post_data)
self.assertTrue(form.is_valid())
@@ -545,7 +543,7 @@ class PermissionsViewTests(TestCase):
)
response = self.c.get(url)
self.assertEqual(response.status_code,200)
self.assertEqual(response.status_code,403)
## Self coach can create one group
## Self coach cannot create more than one group
@@ -629,7 +627,6 @@ class PermissionsViewTests(TestCase):
'name': faker.word(),
}
print 'posting to sessions/create'
form = PlannedSessionForm(post_data)
self.assertTrue(form.is_valid())
@@ -641,7 +638,7 @@ class PermissionsViewTests(TestCase):
## Self Coach cannot edit on behalf of athlete
def test_plan_edit_athlete_settings(self):
self.rbasic.team.add(self.teamplan)
self.rpro.team.add(self.teamplan)
login = self.c.login(username=self.uplan2.username, password=self.uplan2password)
self.assertTrue(login)
@@ -649,12 +646,12 @@ class PermissionsViewTests(TestCase):
url = reverse('rower_prefs_view',kwargs={'userid':self.ubasic.id})
response = self.c.get(url)
self.assertEqual(response.status_code,404)
self.assertEqual(response.status_code,403)
## Self Coach cannot run analytics on behalf of athlete
@patch('rowers.dataprep.read_cols_df_sql', side_effect = mocked_read_df_cols_sql_multistats)
def test_plan_edit_athlete_analysis(self,mocked_df):
self.rbasic.team.add(self.teamplan)
self.rpro.team.add(self.teamplan)
login = self.c.login(username=self.uplan2.username, password=self.uplan2password)
self.assertTrue(login)
@@ -668,13 +665,13 @@ class PermissionsViewTests(TestCase):
response = self.c.get(url)
self.assertEqual(response.status_code,404)
self.assertEqual(response.status_code,403)
## Self Coach cannot upload on behalf of athlete
@patch('rowers.dataprep.create_engine')
@patch('rowers.dataprep.getsmallrowdata_db',side_effect=mocked_getsmallrowdata_db)
def test_plan_edit_athlete_upload(self,mocked_sqlalchemy,mocked_getsmallrowdata_db):
self.rbasic.team.add(self.teamplan)
self.rpro.team.add(self.teamplan)
login = self.c.login(username=self.uplan2.username, password=self.uplan2password)
self.assertTrue(login)
@@ -682,7 +679,7 @@ class PermissionsViewTests(TestCase):
url = reverse('team_workout_upload_view')
response = self.c.get(url)
self.assertEqual(response.status_code,404)
self.assertEqual(response.status_code,403)
## Pro can have one group
@@ -763,7 +760,7 @@ class PermissionsViewTests(TestCase):
## Pro cannot edit on behalf of athlete
def test_pro_edit_athlete_settings(self):
self.rbasic.team.add(self.teampro)
self.rpro.team.add(self.teampro)
login = self.c.login(username=self.upro2.username, password=self.upro2password)
self.assertTrue(login)
@@ -771,12 +768,12 @@ class PermissionsViewTests(TestCase):
url = reverse('rower_prefs_view',kwargs={'userid':self.ubasic.id})
response = self.c.get(url)
self.assertEqual(response.status_code,404)
self.assertEqual(response.status_code,403)
## Pro cannot run analytics on behalf of athlete
@patch('rowers.dataprep.read_cols_df_sql', side_effect = mocked_read_df_cols_sql_multistats)
def test_pro_edit_athlete_analysis(self,mocked_df):
self.rbasic.team.add(self.teampro)
self.rpro.team.add(self.teampro)
login = self.c.login(username=self.upro2.username, password=self.upro2password)
self.assertTrue(login)
@@ -790,40 +787,45 @@ class PermissionsViewTests(TestCase):
response = self.c.get(url)
self.assertEqual(response.status_code,404)
self.assertEqual(response.status_code,403)
## Self Coach cannot upload on behalf of athlete
@patch('rowers.dataprep.create_engine')
@patch('rowers.dataprep.getsmallrowdata_db',side_effect=mocked_getsmallrowdata_db)
def test_plan_edit_athlete_upload(self,mocked_sqlalchemy,mocked_getsmallrowdata_db):
self.rbasic.team.add(self.teamplan)
self.rpro.team.add(self.teamplan)
login = self.c.login(username=self.uplan2.username, password=self.uplan2password)
self.assertTrue(login)
url = reverse('team_workout_upload_view')
response = self.c.get(url)
self.assertEqual(response.status_code,404)
response = self.c.get(url,follow=True)
self.assertEqual(response.status_code,200)
expected_url = reverse('paidplans')
self.assertRedirects(response,
expected_url = expected_url,
status_code=302,target_status_code=200)
## Pro users can see team members' workout, but not edit
def test_coach_edit_athlete_workout(self,mocked_sqlalchemy,mocked_getsmallrowdata_db):
self.rbasic.team.add(self.proplan)
self.rpro2.team.add(self.proplan)
def test_pro_edit_athlete_workout(self):
self.rpro.team.add(self.teampro)
self.rpro2.team.add(self.teampro)
login = self.c.login(username=self.upro2.username, password=self.upro2password)
self.assertTrue(login)
url = reverse('workout_edit_view',
kwargs={'id':encoder.encode_hex(self.ubasic_workouts[0].id)}
kwargs={'id':encoder.encode_hex(self.upro_workouts[0].id)}
)
response = self.c.get(url)
self.assertEqual(response.status_code,404)
self.assertEqual(response.status_code,403)
url = reverse('workout_view',
kwargs={'id':encoder.encode_hex(self.ubasic_workouts[0].id)}
kwargs={'id':encoder.encode_hex(self.upro_workouts[0].id)}
)
response = self.c.get(url)
@@ -831,8 +833,8 @@ class PermissionsViewTests(TestCase):
## Self Coach users can see team members' workout, but not edit
def test_coach_edit_athlete_workout(self,mocked_sqlalchemy,mocked_getsmallrowdata_db):
self.rbasic.team.add(self.teamplan)
def test_plan_edit_athlete_workout(self):
self.rpro.team.add(self.teamplan)
login = self.c.login(username=self.uplan2.username, password=self.uplan2password)
self.assertTrue(login)
@@ -842,7 +844,7 @@ class PermissionsViewTests(TestCase):
)
response = self.c.get(url)
self.assertEqual(response.status_code,200)
self.assertEqual(response.status_code,403)
url = reverse('workout_view',
kwargs={'id':encoder.encode_hex(self.ubasic_workouts[0].id)}
@@ -853,9 +855,9 @@ class PermissionsViewTests(TestCase):
## Basic users can see team members' workout, but not edit
def test_basic_edit_athlete_workout(self,mocked_sqlalchemy,mocked_getsmallrowdata_db):
self.rbasic.team.add(self.teamplan)
self.rplan2.team.add(self.teamplan)
def test_basic_edit_athlete_workout(self):
self.rbasic.team.add(self.teamcoach)
self.rplan2.team.add(self.teamcoach)
login = self.c.login(username=self.ubasic.username, password=self.ubasicpassword)
self.assertTrue(login)
@@ -865,7 +867,7 @@ class PermissionsViewTests(TestCase):
)
response = self.c.get(url)
self.assertEqual(response.status_code,404)
self.assertEqual(response.status_code,403)
url = reverse('workout_view',
kwargs={'id':encoder.encode_hex(self.uplan2_workouts[0].id)}
@@ -902,7 +904,7 @@ class PermissionsViewTests(TestCase):
url = reverse('team_requestmembership_view',
kwargs = {
'teamid':self.teampro.id,
'userid':self.upro.id
'userid':self.ubasic.id
})
response = self.c.get(url,follow=True)
@@ -913,3 +915,8 @@ class PermissionsViewTests(TestCase):
expected_url = expected_url,
status_code=302,target_status_code=200)
# Race related
## Basic and Pro users can create races
## Basic users can subscribe to any race

Binary file not shown.