athlete edit permissions in place
This commit is contained in:
@@ -455,9 +455,10 @@ class PermissionsViewTests(TestCase):
|
||||
|
||||
|
||||
|
||||
## Coach can edit on behalf of athlete
|
||||
## Coach can edit on behalf of athlete if permitted
|
||||
def test_coach_edit_athlete_settings(self):
|
||||
self.rbasic.team.add(self.teamcoach)
|
||||
self.rbasic.coaches.add(self.rcoach)
|
||||
|
||||
login = self.c.login(username=self.ucoach.username, password=self.ucoachpassword)
|
||||
self.assertTrue(login)
|
||||
@@ -467,10 +468,22 @@ class PermissionsViewTests(TestCase):
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
def test_coach_edit_athlete_settings_not(self):
|
||||
self.rbasic.team.add(self.teamcoach)
|
||||
|
||||
login = self.c.login(username=self.ucoach.username, password=self.ucoachpassword)
|
||||
self.assertTrue(login)
|
||||
|
||||
url = reverse('rower_prefs_view',kwargs={'userid':self.ubasic.id})
|
||||
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,403)
|
||||
|
||||
## Coach can run analytics for athlete
|
||||
@patch('rowers.dataprep.read_cols_df_sql', side_effect = mocked_read_df_cols_sql_multistats)
|
||||
def test_coach_edit_athlete_analysis(self,mocked_df):
|
||||
self.rbasic.team.add(self.teamcoach)
|
||||
self.rbasic.coaches.add(self.rcoach)
|
||||
|
||||
login = self.c.login(username=self.ucoach.username, password=self.ucoachpassword)
|
||||
self.assertTrue(login)
|
||||
@@ -486,12 +499,31 @@ class PermissionsViewTests(TestCase):
|
||||
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
@patch('rowers.dataprep.read_cols_df_sql', side_effect = mocked_read_df_cols_sql_multistats)
|
||||
def test_coach_edit_athlete_analysis_not(self,mocked_df):
|
||||
self.rbasic.team.add(self.teamcoach)
|
||||
|
||||
## Coach can upload on behalf of athlete
|
||||
login = self.c.login(username=self.ucoach.username, password=self.ucoachpassword)
|
||||
self.assertTrue(login)
|
||||
|
||||
|
||||
url = reverse('cumstats',
|
||||
kwargs={
|
||||
'theuser':self.ubasic.id,
|
||||
}
|
||||
)
|
||||
|
||||
response = self.c.get(url)
|
||||
|
||||
self.assertEqual(response.status_code,403)
|
||||
|
||||
|
||||
## Coach can upload on behalf of athlete - if team allows
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
@patch('rowers.dataprep.getsmallrowdata_db',side_effect=mocked_getsmallrowdata_db)
|
||||
def test_coach_edit_athlete_upload(self,mocked_sqlalchemy,mocked_getsmallrowdata_db):
|
||||
self.rbasic.team.add(self.teamcoach)
|
||||
self.rbasic.coaches.add(self.rcoach)
|
||||
|
||||
login = self.c.login(username=self.ucoach.username, password=self.ucoachpassword)
|
||||
self.assertTrue(login)
|
||||
@@ -531,6 +563,50 @@ class PermissionsViewTests(TestCase):
|
||||
|
||||
self.assertEqual(aantal2,aantal+1)
|
||||
|
||||
## Coach can upload on behalf of athlete - if team allows
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
@patch('rowers.dataprep.getsmallrowdata_db',side_effect=mocked_getsmallrowdata_db)
|
||||
def test_coach_edit_athlete_uploadnot(self,mocked_sqlalchemy,mocked_getsmallrowdata_db):
|
||||
self.rbasic.team.add(self.teamcoach)
|
||||
|
||||
login = self.c.login(username=self.ucoach.username, password=self.ucoachpassword)
|
||||
self.assertTrue(login)
|
||||
|
||||
url = reverse('team_workout_upload_view')
|
||||
|
||||
aantal = len(Workout.objects.filter(user=self.rbasic))
|
||||
|
||||
response = self.c.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
filename = 'rowers/tests/testdata/testdata.csv'
|
||||
f = open(filename,'rb')
|
||||
file_data = {'file': f}
|
||||
form_data = {
|
||||
'title':'test',
|
||||
'workouttype':'rower',
|
||||
'boattype':'1x',
|
||||
'notes':'aap noot mies',
|
||||
'make_plot':False,
|
||||
'upload_to_c2':False,
|
||||
'plottype':'timeplot',
|
||||
'file': f,
|
||||
'user': self.ubasic.id
|
||||
}
|
||||
|
||||
response = self.c.post(url, form_data, follow=True)
|
||||
f.close()
|
||||
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
self.assertRedirects(response,
|
||||
expected_url = url,
|
||||
status_code=302,target_status_code=200)
|
||||
|
||||
aantal2 = len(Workout.objects.filter(user=self.rbasic))
|
||||
|
||||
self.assertEqual(aantal2,aantal)
|
||||
|
||||
## Coach can edit athlete's workout
|
||||
def test_coach_edit_athlete_workout(self):
|
||||
self.rbasic.team.add(self.teamcoach)
|
||||
|
||||
Reference in New Issue
Block a user