@@ -73,58 +73,6 @@ def test_restricted_admin_route_is_forbidden(
7373 assert res .status_code == 403
7474
7575
76- @patch ("services.mongodb_handler.retrieve" , autospec = True )
77- @patch ("services.mongodb_handler.retrieve_one" , autospec = True )
78- def test_can_retrieve_applicants (
79- mock_mongodb_handler_retrieve_one : AsyncMock ,
80- mock_mongodb_handler_retrieve : AsyncMock ,
81- ) -> None :
82- """Test that the applicants summary can be processed."""
83-
84- mock_mongodb_handler_retrieve_one .side_effect = [
85- HACKER_REVIEWER_IDENTITY ,
86- {"accept" : 8 , "waitlist" : 5 },
87- ]
88- mock_mongodb_handler_retrieve .return_value = [
89- {
90- "_id" : "edu.uci.petr" ,
91- "first_name" : "Peter" ,
92- "last_name" : "Anteater" ,
93- "status" : "REVIEWED" ,
94- "application_data" : {
95- "school" : "UC Irvine" ,
96- "submission_time" : datetime (2023 , 1 , 12 , 9 , 0 , 0 ),
97- "reviews" : [
98- [datetime (2023 , 1 , 18 ), "edu.uci.alicia" , 8 ],
99- [datetime (2023 , 1 , 18 ), "edu.uci.albert" , 9 ],
100- ],
101- },
102- },
103- ]
104-
105- res = reviewer_client .get ("/applicants/hackers" )
106-
107- assert res .status_code == 200
108- mock_mongodb_handler_retrieve .assert_awaited_once ()
109- data = res .json ()
110- assert data == [
111- {
112- "_id" : "edu.uci.petr" ,
113- "first_name" : "Peter" ,
114- "last_name" : "Anteater" ,
115- "resume_reviewed" : False ,
116- "avg_score" : 8.5 ,
117- "reviewers" : ["edu.uci.albert" , "edu.uci.alicia" ],
118- "status" : "REVIEWED" ,
119- "decision" : "ACCEPTED" ,
120- "application_data" : {
121- "school" : "UC Irvine" ,
122- "submission_time" : "2023-01-12T09:00:00" ,
123- },
124- },
125- ]
126-
127-
12876@patch ("services.mongodb_handler.retrieve" , autospec = True )
12977@patch ("services.mongodb_handler.retrieve_one" , autospec = True )
13078def test_cannot_retrieve_applicants_without_role (
@@ -334,6 +282,64 @@ def test_non_waitlisted_applicant_cannot_be_released(
334282 mock_mongodb_handler_update_one .assert_not_awaited ()
335283
336284
285+ # TODO: Should uncomment once new applicant summary is created at different route
286+ # @patch("services.mongodb_handler.retrieve_one", autospec=True)
287+ # @patch("services.mongodb_handler.retrieve", autospec=True)
288+ # def test_hacker_applicants_returns_correct_applicants(
289+ # mock_mongodb_handler_retrieve: AsyncMock,
290+ # mock_mongodb_handler_retrieve_one: AsyncMock,
291+ # ) -> None:
292+ # """Test that the /applicants/hackers route returns correctly"""
293+ # returned_records: list[dict[str, object]] = [
294+ # {
295+ # "_id": "edu.uci.sydnee",
296+ # "first_name": "sydnee",
297+ # "last_name": "unknown",
298+ # "status": "REVIEWED",
299+ # "application_data": {
300+ # "school": "Hamburger University",
301+ # "submission_time": datetime(2023, 1, 12, 9, 0, 0),
302+ # "reviews": [
303+ # [datetime(2023, 1, 19), "edu.uci.alicia", 100],
304+ # [datetime(2023, 1, 19), "edu.uci.alicia2", 200],
305+ # ],
306+ # },
307+ # }
308+ # ]
309+
310+ # expected_records = [
311+ # {
312+ # "_id": "edu.uci.sydnee",
313+ # "first_name": "sydnee",
314+ # "last_name": "unknown",
315+ # "resume_reviewed": False,
316+ # "status": "REVIEWED",
317+ # "decision": "ACCEPTED",
318+ # "avg_score": 150.0,
319+ # "reviewers": ["edu.uci.alicia", "edu.uci.alicia2"],
320+ # "application_data": {
321+ # "school": "Hamburger University",
322+ # "submission_time": "2023-01-12T09:00:00",
323+ # },
324+ # },
325+ # ]
326+
327+ # returned_thresholds: dict[str, object] = {"accept": 12, "waitlist": 5}
328+
329+ # mock_mongodb_handler_retrieve.return_value = returned_records
330+ # mock_mongodb_handler_retrieve_one.side_effect = [
331+ # HACKER_REVIEWER_IDENTITY,
332+ # returned_thresholds,
333+ # ]
334+
335+ # res = reviewer_client.get("/applicants/hackers")
336+
337+ # assert res.status_code == 200
338+ # mock_mongodb_handler_retrieve.assert_awaited_once()
339+ # data = res.json()
340+ # assert data == expected_records
341+
342+
337343@patch ("services.mongodb_handler.retrieve_one" , autospec = True )
338344@patch ("services.mongodb_handler.retrieve" , autospec = True )
339345def test_hacker_applicants_returns_correct_applicants (
@@ -351,9 +357,28 @@ def test_hacker_applicants_returns_correct_applicants(
351357 "school" : "Hamburger University" ,
352358 "submission_time" : datetime (2023 , 1 , 12 , 9 , 0 , 0 ),
353359 "reviews" : [
354- [datetime (2023 , 1 , 19 ), "edu.uci.alicia" , 100 ],
355- [datetime (2023 , 1 , 19 ), "edu.uci.alicia2" , 200 ],
360+ [datetime (2023 , 1 , 19 ), "edu.uci.alicia" , 56 ],
361+ [datetime (2023 , 1 , 19 ), "edu.uci.alicia2" , 60 ],
356362 ],
363+ "review_breakdown" : {
364+ "alicia" : {
365+ "resume" : 15 ,
366+ "elevator_pitch_saq" : 6 ,
367+ "tech_experience_saq" : 6 ,
368+ "learn_about_self_saq" : 8 ,
369+ "pixel_art_saq" : 16 ,
370+ "hackathon_experience" : - 1000 ,
371+ },
372+ "alicia2" : {
373+ "resume" : 15 ,
374+ "elevator_pitch_saq" : 10 ,
375+ "tech_experience_saq" : 10 ,
376+ "learn_about_self_saq" : 10 ,
377+ "pixel_art_saq" : 10 ,
378+ "hackathon_experience" : 5 ,
379+ },
380+ },
381+ "global_field_scores" : {"resume" : 15 , "hackathon_experience" : 5 },
357382 },
358383 }
359384 ]
@@ -363,10 +388,10 @@ def test_hacker_applicants_returns_correct_applicants(
363388 "_id" : "edu.uci.sydnee" ,
364389 "first_name" : "sydnee" ,
365390 "last_name" : "unknown" ,
366- "resume_reviewed" : False ,
391+ "resume_reviewed" : True ,
367392 "status" : "REVIEWED" ,
368393 "decision" : "ACCEPTED" ,
369- "avg_score" : 150 .0 ,
394+ "avg_score" : 58 .0 ,
370395 "reviewers" : ["edu.uci.alicia" , "edu.uci.alicia2" ],
371396 "application_data" : {
372397 "school" : "Hamburger University" ,
0 commit comments