Private
Public Access
1
0

going through the tests

This commit is contained in:
2024-12-31 12:47:44 +01:00
parent 2759fd56eb
commit 58f66fbd11
9 changed files with 62 additions and 84 deletions

View File

@@ -866,7 +866,7 @@ class PermissionsViewTests(TestCase):
status_code=302,target_status_code=200)
# Create 2nd new team - should redirect to paid plans
# Create 2nd new team - should not redirect to paid plans
form_data = {
'name': faker.word(),
'notes': faker.text(),
@@ -883,12 +883,12 @@ class PermissionsViewTests(TestCase):
expected_url = reverse('paidplans_view')
response = self.c.post(url,form_data,follow=True)
self.assertRedirects(response,
expected_url=expected_url,
status_code=302,target_status_code=200)
# check that it does not redirect and status code is 200
self.assertEqual(response.status_code,200)
## Self Coach can create planned sessions and team planned sessions
## Pro can create planned sessions and team planned sessions
def test_plan_create_session(self):
login = self.c.login(username=self.uplan2.username, password=self.uplan2password)
self.assertTrue(login)
@@ -929,24 +929,24 @@ class PermissionsViewTests(TestCase):
self.assertEqual(response.status_code,200)
## Self Coach cannot edit on behalf of athlete
## Team Manager cannot edit on behalf of athlete
def test_plan_edit_athlete_settings(self):
self.rpro.team.add(self.teampro)
login = self.c.login(username=self.uplan2.username, password=self.uplan2password)
login = self.c.login(username=self.upro2.username, password=self.upro2password)
self.assertTrue(login)
url = reverse('rower_prefs_view',kwargs={'userid':self.ubasic.id})
response = self.c.get(url)
self.assertEqual(response.status_code,200)
self.assertEqual(response.status_code,403)
## Self Coach cannot run analytics on behalf of athlete
## Team Manager 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.rpro.team.add(self.teampro)
login = self.c.login(username=self.uplan2.username, password=self.uplan2password)
login = self.c.login(username=self.upro2.username, password=self.upro2password)
self.assertTrue(login)
@@ -958,22 +958,45 @@ class PermissionsViewTests(TestCase):
response = self.c.get(url)
self.assertEqual(response.status_code,200)
self.assertEqual(response.status_code,403)
## Self Coach cannot upload on behalf of athlete
## Team Manager cannot upload on behalf of athlete
@patch('rowers.dataprep.create_engine')
@patch('rowers.dataprep.read_data',side_effect=mocked_read_data)
def test_plan_edit_athlete_upload(self,mocked_sqlalchemy,mocked_read_data):
self.rpro.team.add(self.teampro)
login = self.c.login(username=self.uplan2.username, password=self.uplan2password)
login = self.c.login(username=self.upro2.username, password=self.upro2password)
self.assertTrue(login)
url = reverse('team_workout_upload_view')
# can get to the page
response = self.c.get(url)
self.assertEqual(response.status_code,200)
# cannot post the form
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.upro.id
}
response = self.c.post(url, form_data, follow=True)
f.close()
# check that form errors are present in response content
self.assertContains(response,'Select a valid choice. That choice is not one of the available choices.')
## Pro can have more than one group
def test_pro_groups_create(self):
@@ -1007,7 +1030,7 @@ class PermissionsViewTests(TestCase):
status_code=302,target_status_code=200)
# Create 2nd new team - should redirect to paid plans
# Create 2nd new team - should not redirect to paid plans
form_data = {
'name': faker.word(),
'notes': faker.text(),
@@ -1029,7 +1052,7 @@ class PermissionsViewTests(TestCase):
status_code=302,target_status_code=200)
## Pro cannot create planned sessions or team planned sessions
## Pro can create planned sessions or team planned sessions
def test_pro_create_session(self):
login = self.c.login(username=self.upro2.username, password=self.upro2password)
self.assertTrue(login)
@@ -1040,48 +1063,9 @@ class PermissionsViewTests(TestCase):
enddate = (nu+datetime.timedelta(days=3)).date()
preferreddate = startdate
response = self.c.get(url,follow=True)
response = self.c.get(url,follow=False)
self.assertEqual(response.status_code,200)
expected_url = reverse('paidplans_view')
self.assertRedirects(response,
expected_url=expected_url,
status_code=302,target_status_code=200)
## Pro cannot edit on behalf of athlete
def test_pro_edit_athlete_settings(self):
self.rpro.team.add(self.teampro)
login = self.c.login(username=self.upro2.username, password=self.upro2password)
self.assertTrue(login)
url = reverse('rower_prefs_view',kwargs={'userid':self.ubasic.id})
response = self.c.get(url)
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):
with transaction.atomic():
self.rpro.team.add(self.teampro)
login = self.c.login(username=self.upro2.username, password=self.upro2password)
self.assertTrue(login)
url = reverse('analysis_new',
kwargs={
'userid':self.ubasic.id,
}
)
response = self.c.get(url)
self.assertEqual(response.status_code,403)
## Basic users can see team members' workout, but not edit
def test_basic_edit_athlete_workout(self):