@@ -200,3 +200,37 @@ def test_rate_course_update_existing(user_token, course_id):
200200 data2 = resp2 .json ()
201201 assert data2 ["value" ] == 5
202202 assert data2 ["id" ] == data1 ["id" ] # Should update the same rating, not create a new one
203+
204+
205+ def test_get_single_rating (user_token , course_id ):
206+ """Test retrieving a specific rating by ID."""
207+ # Rate the course
208+ resp = client .post (
209+ f"{ API_PREFIX } /courses/{ course_id } /ratings/" ,
210+ json = {"value" : 4 },
211+ headers = auth_headers (user_token )
212+ )
213+ assert resp .status_code in (200 , 201 )
214+ rating_id = resp .json ()["id" ]
215+
216+ # Retrieve all ratings for the course and check the specific rating is present
217+ resp_all = client .get (f"{ API_PREFIX } /courses/{ course_id } /ratings/" )
218+ assert resp_all .status_code == 200
219+ ratings = resp_all .json ()
220+ assert any (r ["id" ] == rating_id for r in ratings )
221+
222+
223+ def test_get_all_ratings_for_user (user_token , course_id ):
224+ """Test retrieving all ratings made by the current user."""
225+ # Rate the course
226+ client .post (
227+ f"{ API_PREFIX } /courses/{ course_id } /ratings/" ,
228+ json = {"value" : 5 },
229+ headers = auth_headers (user_token )
230+ )
231+ # Retrieve all ratings for the user
232+ resp = client .get (f"{ API_PREFIX } /users/me/ratings/" , headers = auth_headers (user_token ))
233+ assert resp .status_code == 200
234+ ratings = resp .json ()
235+ assert isinstance (ratings , list )
236+ assert any (r ["course_id" ] == course_id for r in ratings )
0 commit comments