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

@@ -65,7 +65,7 @@ class RojaboObjects(DjangoTestCase):
self.r2.rojabo_refreshtoken = 'ab'
self.r2.rojabo_tokenexpirydate = arrow.get(datetime.datetime.now()+datetime.timedelta(days=1)).datetime
self.r2.defaulttimezone = 'Europe/Prague'
self.r2.rowerplan = 'pro'
self.r2.rowerplan = 'basic'
self.r2.save()
self.nu = datetime.datetime.now()

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):

Binary file not shown.

View File

@@ -23,14 +23,14 @@
24,26,addmanual_view,upload a manual workout,TRUE,302,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
26,28,workouts_join_view,join workouts,TRUE,302,pro,302,302,pro,403,403,coach,302,403,FALSE,TRUE,FALSE,TRUE,TRUE,
27,29,workouts_join_select,select workouts to join,TRUE,404,pro,200,302,pro,403,403,coach,200,403,FALSE,TRUE,FALSE,TRUE,TRUE,
29,31,analysis_new,analysis front page,TRUE,302,pro,200,302,FALSE,200,302,coach,200,302,FALSE,TRUE,FALSE,TRUE,TRUE,
29,31,analysis_new,analysis front page,TRUE,404,pro,200,302,FALSE,200,302,coach,200,302,FALSE,TRUE,FALSE,TRUE,TRUE,
31,33,session_jobs_view,view jobs,TRUE,302,basic,200,302,FALSE,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
32,34,session_jobs_status,view jobs,TRUE,302,basic,200,302,FALSE,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
33,35,kill_async_job,kill job,TRUE,302,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
34,36,post_progress,post progress,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
35,37,graphs_view,view charts,TRUE,302,basic,200,302,basic,200,302,coach,200,302,FALSE,TRUE,FALSE,TRUE,TRUE,
41,43,cum_flex,flex all chart,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
42,44,analysis_view_data,redirects to analysis direct,TRUE,302,pro,200,302,pro,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
42,44,analysis_view_data,redirects to analysis direct,TRUE,404,pro,200,302,pro,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
43,47,cum_flex_data,flex all chart data (json),TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
47,53,graph_show_view,show a chart,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
48,54,GraphDelete,delete a chart,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
@@ -110,7 +110,7 @@
148,188,coach_accept_coachrequest_view,Accept Coach request,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
149,189,rower_accept_coachoffer_view,Accept Coach offer,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
150,190,team_delete_view,Delete Team,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
151,191,team_create_view,Create Team,TRUE,302,pro,302,302,FALSE,200,200,FALSE,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
151,191,team_create_view,Create Team,TRUE,302,pro,200,302,FALSE,200,200,FALSE,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
152,192,manager_member_drop_view,Drop member,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
153,193,invitation_reject_view,Reject invitation,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
154,194,invitation_revoke_view,redirects when no invitations,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
@@ -151,11 +151,9 @@
193,249,checkouts_view,checkout,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
194,250,upgrade_checkouts_view,upgrade checkout,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
195,251,downgrade_checkouts_view,downgrade checkout,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
196,252,planrequired_view,a plan is required,TRUE,302,basic,302,302,basic,302,302,coach,302,302,FALSE,FALSE,FALSE,TRUE,TRUE,
197,253,start_trial_view,payments,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
198,254,start_plantrial_view,paid plans,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
199,256,rower_register_view,register rower,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
200,257,freecoach_register_view,register coach,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
201,259,workout_workflow_view,workout workflow vieq,TRUE,302,basic,200,200,basic,200,200,coach,200,200,FALSE,FALSE,TRUE,TRUE,TRUE,
202,260,workout_flexchart3_view,flex chart,TRUE,302,basic,200,403,basic,200,200,coach,200,200,FALSE,FALSE,TRUE,TRUE,TRUE,
203,264,rower_process_testcallback,test callback,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
@@ -178,8 +176,8 @@
220,292,plannedsession_teamcreate_view,create planned session for team,TRUE,302,pro,200,302,FALSE,200,302,FALSE,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
221,296,plannedsession_teamedit_view,edit planned sesssion,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
222,298,plannedsession_create_view,create planned session ,TRUE,302,pro,200,302,FALSE,200,302,coach,200,403,FALSE,TRUE,FALSE,TRUE,TRUE,
223,300,plannedsession_multiclone_view,clone multiple planned sessions,TRUE,302,pro,200,302,pro,403,403,coach,200,403,FALSE,TRUE,FALSE,TRUE,TRUE,
224,302,plannedsession_multicreate_view,create multiple planned sessions,TRUE,302,pro,200,302,pro,403,403,coach,200,403,FALSE,TRUE,FALSE,TRUE,TRUE,
223,300,plannedsession_multiclone_view,clone multiple planned sessions,TRUE,302,pro,200,302,pro,200,403,coach,200,403,FALSE,TRUE,FALSE,TRUE,TRUE,
224,302,plannedsession_multicreate_view,create multiple planned sessions,TRUE,302,pro,200,302,pro,200,403,coach,200,403,FALSE,TRUE,FALSE,TRUE,TRUE,
225,305,plannedsession_edit_view,edit planned sesssion,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
226,306,plannedsession_totemplate_view,planned session to template,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
227,307,plannedsession_compare_view,compare workouts from planned session,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
@@ -264,5 +262,5 @@
308,603,failed_queue_view,Other Apps views,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
309,604,failed_queue_empty,Other Apps views,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
310,605,failed_job_view,Other Apps views,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE,FALSE,
311,49,performancemanager_view,Performance Manager,TRUE,302,pro,200,302,pro,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
311,49,performancemanager_view,Performance Manager,TRUE,404,pro,200,302,pro,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
312,606,workout_flexchart_stacked_view,flex chart,TRUE,302,basic,200,403,basic,200,200,coach,200,200,FALSE,FALSE,TRUE,TRUE,TRUE,
1 id view function anonymous anonymous_response own own_response own_nonperm member member_response member_nonperm coachee coachee_response coachee_nonperm is_staff userid workoutid dotest realtest kwargs
23 24 26 addmanual_view upload a manual workout TRUE 302 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE TRUE TRUE
24 26 28 workouts_join_view join workouts TRUE 302 pro 302 302 pro 403 403 coach 302 403 FALSE TRUE FALSE TRUE TRUE
25 27 29 workouts_join_select select workouts to join TRUE 404 pro 200 302 pro 403 403 coach 200 403 FALSE TRUE FALSE TRUE TRUE
26 29 31 analysis_new analysis front page TRUE 302 404 pro 200 302 FALSE 200 302 coach 200 302 FALSE TRUE FALSE TRUE TRUE
27 31 33 session_jobs_view view jobs TRUE 302 basic 200 302 FALSE 200 302 coach 200 302 FALSE FALSE FALSE TRUE TRUE
28 32 34 session_jobs_status view jobs TRUE 302 basic 200 302 FALSE 200 302 coach 200 302 FALSE FALSE FALSE TRUE TRUE
29 33 35 kill_async_job kill job TRUE 302 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
30 34 36 post_progress post progress TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
31 35 37 graphs_view view charts TRUE 302 basic 200 302 basic 200 302 coach 200 302 FALSE TRUE FALSE TRUE TRUE
32 41 43 cum_flex flex all chart TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
33 42 44 analysis_view_data redirects to analysis direct TRUE 302 404 pro 200 302 pro 200 302 coach 200 302 FALSE FALSE FALSE TRUE TRUE
34 43 47 cum_flex_data flex all chart data (json) TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
35 47 53 graph_show_view show a chart TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
36 48 54 GraphDelete delete a chart TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
110 148 188 coach_accept_coachrequest_view Accept Coach request TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
111 149 189 rower_accept_coachoffer_view Accept Coach offer TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
112 150 190 team_delete_view Delete Team TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
113 151 191 team_create_view Create Team TRUE 302 pro 302 200 302 FALSE 200 200 FALSE 200 302 FALSE FALSE FALSE TRUE TRUE
114 152 192 manager_member_drop_view Drop member TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
115 153 193 invitation_reject_view Reject invitation TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
116 154 194 invitation_revoke_view redirects when no invitations TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
151 193 249 checkouts_view checkout TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
152 194 250 upgrade_checkouts_view upgrade checkout TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
153 195 251 downgrade_checkouts_view downgrade checkout TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
196 252 planrequired_view a plan is required TRUE 302 basic 302 302 basic 302 302 coach 302 302 FALSE FALSE FALSE TRUE TRUE
154 197 253 start_trial_view payments TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
155 198 254 start_plantrial_view paid plans TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
156 199 256 rower_register_view register rower TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE TRUE TRUE
200 257 freecoach_register_view register coach TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE TRUE TRUE
157 201 259 workout_workflow_view workout workflow vieq TRUE 302 basic 200 200 basic 200 200 coach 200 200 FALSE FALSE TRUE TRUE TRUE
158 202 260 workout_flexchart3_view flex chart TRUE 302 basic 200 403 basic 200 200 coach 200 200 FALSE FALSE TRUE TRUE TRUE
159 203 264 rower_process_testcallback test callback TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
176 220 292 plannedsession_teamcreate_view create planned session for team TRUE 302 pro 200 302 FALSE 200 302 FALSE 200 302 FALSE FALSE FALSE TRUE TRUE
177 221 296 plannedsession_teamedit_view edit planned sesssion TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
178 222 298 plannedsession_create_view create planned session TRUE 302 pro 200 302 FALSE 200 302 coach 200 403 FALSE TRUE FALSE TRUE TRUE
179 223 300 plannedsession_multiclone_view clone multiple planned sessions TRUE 302 pro 200 302 pro 403 200 403 coach 200 403 FALSE TRUE FALSE TRUE TRUE
180 224 302 plannedsession_multicreate_view create multiple planned sessions TRUE 302 pro 200 302 pro 403 200 403 coach 200 403 FALSE TRUE FALSE TRUE TRUE
181 225 305 plannedsession_edit_view edit planned sesssion TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
182 226 306 plannedsession_totemplate_view planned session to template TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
183 227 307 plannedsession_compare_view compare workouts from planned session TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
262 308 603 failed_queue_view Other Apps views TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
263 309 604 failed_queue_empty Other Apps views TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE FALSE FALSE FALSE
264 310 605 failed_job_view Other Apps views TRUE 200 basic 200 302 basic 200 302 coach 200 302 FALSE FALSE TRUE FALSE FALSE
265 311 49 performancemanager_view Performance Manager TRUE 302 404 pro 200 302 pro 200 302 coach 200 302 FALSE FALSE FALSE TRUE TRUE
266 312 606 workout_flexchart_stacked_view flex chart TRUE 302 basic 200 403 basic 200 200 coach 200 200 FALSE FALSE TRUE TRUE TRUE