@@ -14,7 +14,9 @@ def task_with_submissions(db, approach_factory, submission_factory, task_factory
1414 - an approach where the most recent score is worse than a prior score (t1_a0)
1515 - a team with a better approach which has been rejected (t3)
1616 """
17- task = task_factory (challenge__name = 'Test Challenge' , name = 'Test Task' , scores_published = True )
17+ task = task_factory (
18+ challenge__name = 'Test Challenge' , name = 'Test Task' , scores_published = True , hidden = False
19+ )
1820
1921 teams = [
2022 team_factory (challenge = task .challenge ),
@@ -66,47 +68,53 @@ def task_with_submissions(db, approach_factory, submission_factory, task_factory
6668
6769@pytest .mark .django_db
6870def test_leaderboard_by_approach (task_with_submissions , client ):
69- resp = client .get (f'/api/leaderboard/{ task_with_submissions .id } /by-approach/' )
71+ resp = client .get (
72+ f'/leaderboards/{ task_with_submissions .challenge .slug } /?task={ task_with_submissions .id } &group_by=approach' # noqa: E501
73+ )
7074 assert resp .status_code == 200
7175
7276 # assert the by approach leaderboard looks like
7377 # team0 | approach0 | .95
7478 # team0 | approach1 | .80
7579 # team1 | approach1 | .78
7680 # team3 | approach1 | .60
77- first , second , third , fourth = resp .json ()['results' ]
78-
79- assert first ['team_name' ] == 'team_0'
80- assert first ['approach_name' ] == 'approach_0'
81- assert first ['overall_score' ] == 0.95
82- assert second ['team_name' ] == 'team_0'
83- assert second ['approach_name' ] == 'approach_1'
84- assert second ['overall_score' ] == 0.80
85- assert third ['team_name' ] == 'team_1'
86- assert third ['approach_name' ] == 'approach_0'
87- assert third ['overall_score' ] == 0.78
88- assert fourth ['team_name' ] == 'team_3'
89- assert fourth ['approach_name' ] == 'approach_1'
90- assert fourth ['overall_score' ] == 0.60
81+ submissions = resp .context ['submissions' ]
82+ first , second , third , fourth = submissions [:4 ]
83+
84+ assert first .approach .team .name == 'team_0'
85+ assert first .approach .name == 'approach_0'
86+ assert first .overall_score == 0.95
87+ assert second .approach .team .name == 'team_0'
88+ assert second .approach .name == 'approach_1'
89+ assert second .overall_score == 0.80
90+ assert third .approach .team .name == 'team_1'
91+ assert third .approach .name == 'approach_0'
92+ assert third .overall_score == 0.78
93+ assert fourth .approach .team .name == 'team_3'
94+ assert fourth .approach .name == 'approach_1'
95+ assert fourth .overall_score == 0.60
9196
9297
9398@pytest .mark .django_db
9499def test_leaderboard_by_team (task_with_submissions , client ):
95- resp = client .get (f'/api/leaderboard/{ task_with_submissions .id } /by-team/' )
100+ resp = client .get (
101+ f'/leaderboards/{ task_with_submissions .challenge .slug } /?task={ task_with_submissions .id } &group_by=team' # noqa: E501
102+ )
96103 assert resp .status_code == 200
97104
98105 # assert the by team leaderboard looks like
99106 # team4 | approach0 | .95
100107 # team5 | approach0 | .78
101108 # team7 | approach1 | .60
102- first , second , third = resp .json ()['results' ]
103-
104- assert first ['team_name' ] == 'team_5'
105- assert first ['approach_name' ] == 'approach_0'
106- assert first ['overall_score' ] == 0.95
107- assert second ['team_name' ] == 'team_6'
108- assert second ['approach_name' ] == 'approach_0'
109- assert second ['overall_score' ] == 0.78
110- assert third ['team_name' ] == 'team_8'
111- assert third ['approach_name' ] == 'approach_1'
112- assert third ['overall_score' ] == 0.60
109+ submissions = resp .context ['submissions' ]
110+ first , second , third = submissions [:3 ]
111+
112+ assert first .approach .team .name == 'team_5'
113+ assert first .approach .name == 'approach_0'
114+ assert first .overall_score == 0.95
115+ assert second .approach .team .name == 'team_6'
116+ assert second .approach .name == 'approach_0'
117+ assert second .overall_score == 0.78
118+ assert third .approach .team .name == 'team_8'
119+ assert third .approach .name == 'approach_1'
120+ assert third .overall_score == 0.60
0 commit comments