test(search): Adopt test do use same serializer as view

This commit is contained in:
Georg Krause 2022-10-13 11:46:17 +02:00
parent 4b1baec347
commit e8b7da9744
No known key found for this signature in database
GPG Key ID: 2970D504B2183D22
2 changed files with 9 additions and 7 deletions

View File

@ -838,7 +838,7 @@ class Search(views.APIView):
if "in tsquery:" in str(e): if "in tsquery:" in str(e):
return Response( return Response(
{"detail": "Invalid query"}, status=400 {"detail": "Invalid query"}, status=400
) # TODO This might be better a 500? )
else: else:
raise raise

View File

@ -1346,12 +1346,14 @@ def test_search_get(logged_in_api_client, factories):
factories["tags.Tag"]() factories["tags.Tag"]()
url = reverse("api:v1:search") url = reverse("api:v1:search")
expected = { expected = serializers.SearchResultSerializer(
"artists": [serializers.ArtistWithAlbumsSerializer(artist).data], {
"albums": [serializers.AlbumSerializer(album).data], "artists": [artist],
"tracks": [serializers.TrackSerializer(track).data], "albums": [album],
"tags": [views.TagSerializer(tag).data], "tracks": [track],
} "tags": [tag],
}
).data
response = logged_in_api_client.get(url, {"q": "foo"}) response = logged_in_api_client.get(url, {"q": "foo"})