Commit 77973ba6 authored by Eliot Berriot's avatar Eliot Berriot 💬

See #574: linting

parent bf3b3854
......@@ -557,7 +557,9 @@ class UploadQuerySet(models.QuerySet):
libraries = Library.objects.viewable_by(actor)
if include:
return self.filter(library__in=libraries, import_status="finished").distinct()
return self.filter(
library__in=libraries, import_status="finished"
).distinct()
return self.exclude(library__in=libraries, import_status="finished").distinct()
def local(self, include=True):
......
......@@ -235,7 +235,9 @@ class SubsonicViewSet(viewsets.GenericViewSet):
except (TypeError, KeyError, ValueError):
size = 50
queryset = queryset.playable_by(actor).prefetch_related('uploads').order_by("?")[:size]
queryset = (
queryset.playable_by(actor).prefetch_related("uploads").order_by("?")[:size]
)
data = {
"randomSongs": {
"song": serializers.GetSongSerializer(queryset, many=True).data
......
......@@ -254,13 +254,15 @@ def test_get_random_songs(f, db, logged_in_api_client, factories, mocker):
factories["music.Track"]()
order_by = mocker.patch.object(
music_models.TrackQuerySet, 'order_by', return_value=[track1, track2]
music_models.TrackQuerySet, "order_by", return_value=[track1, track2]
)
response = logged_in_api_client.get(url, {"f": f, "size": 2})
assert response.status_code == 200
assert response.data == {
"randomSongs": {"song": serializers.GetSongSerializer([track1, track2], many=True).data}
"randomSongs": {
"song": serializers.GetSongSerializer([track1, track2], many=True).data
}
}
order_by.assert_called_once_with("?")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment