@@ -153,6 +153,38 @@ def test_media_list_get_with_sort_filter_returns_sorted_results(self):
153153 titles = [item ["item" ]["title" ] for item in payload ["results" ]]
154154 self .assertEqual (titles , sorted (titles , reverse = True ))
155155
156+ def test_media_list_get_sorts_by_user_score (self ):
157+ """Media list accepts score as a tracked-media sort field."""
158+ for media , score in zip (self .movie_medias , (7 , 9 , 8 ), strict = True ):
159+ media .score = score
160+ media .save (update_fields = ["score" ])
161+
162+ response = self .call_api (
163+ "get" ,
164+ "api_media_list" ,
165+ params = {"media_type" : MediaTypes .MOVIE .value , "sort" : "score_desc" },
166+ headers = self .auth_headers ,
167+ )
168+
169+ self .assertEqual (response .status_code , 200 )
170+ self .assertEqual (
171+ [item ["score" ] for item in response .json ()["results" ]],
172+ [9 , 8 , 7 ],
173+ )
174+
175+ response = self .call_api (
176+ "get" ,
177+ "api_media_list" ,
178+ params = {"sort" : "score_desc" },
179+ headers = self .auth_headers ,
180+ )
181+
182+ self .assertEqual (response .status_code , 200 )
183+ self .assertEqual (
184+ [item ["score" ] for item in response .json ()["results" ][:3 ]],
185+ [9 , 8 , 7 ],
186+ )
187+
156188 def test_media_list_get_with_exclude_filter_excludes_type (self ):
157189 """Media list endpoint should exclude requested media types."""
158190 response = self .call_api (
0 commit comments