1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Fix getting starred stuff

Closes #246
This commit is contained in:
Alban Féron 2023-02-25 16:30:05 +01:00
parent 245e9c7c54
commit 8e2adf8fc8
No known key found for this signature in database
GPG Key ID: 8CE0313646D16165
2 changed files with 32 additions and 7 deletions

View File

@ -270,9 +270,11 @@ def get_starred():
return request.formatter( return request.formatter(
"starred", "starred",
{ {
"artist": [sf.as_subsonic_artist(request.user) for sf in arq], "artist": [sf.starred.as_subsonic_artist(request.user) for sf in arq],
"album": [sf.as_subsonic_child(request.user) for sf in alq], "album": [sf.starred.as_subsonic_child(request.user) for sf in alq],
"song": [st.as_subsonic_child(request.user, request.client) for st in trq], "song": [
st.starred.as_subsonic_child(request.user, request.client) for st in trq
],
}, },
) )
@ -306,8 +308,10 @@ def get_starred_id3():
return request.formatter( return request.formatter(
"starred2", "starred2",
{ {
"artist": [sa.as_subsonic_artist(request.user) for sa in arq], "artist": [sa.starred.as_subsonic_artist(request.user) for sa in arq],
"album": [sa.as_subsonic_album(request.user) for sa in alq], "album": [sa.starred.as_subsonic_album(request.user) for sa in alq],
"song": [st.as_subsonic_child(request.user, request.client) for st in trq], "song": [
st.starred.as_subsonic_child(request.user, request.client) for st in trq
],
}, },
) )

View File

@ -7,7 +7,17 @@
import unittest import unittest
from supysonic.db import Folder, Artist, Album, Track from supysonic.db import (
Folder,
Artist,
Album,
Track,
StarredArtist,
StarredAlbum,
StarredFolder,
StarredTrack,
User,
)
from .apitestbase import ApiTestBase from .apitestbase import ApiTestBase
@ -260,11 +270,22 @@ class AlbumSongsTestCase(ApiTestBase):
def test_now_playing(self): def test_now_playing(self):
self._make_request("getNowPlaying", tag="nowPlaying") self._make_request("getNowPlaying", tag="nowPlaying")
def _create_starred_info(self):
user = User.select().first()
StarredArtist.create(user=user, starred=Artist.select().first())
StarredAlbum.create(user=user, starred=Album.select().first())
StarredTrack.create(user=user, starred=Track.select().first())
StarredFolder.create(user=user, starred=Folder.select().first())
def test_get_starred(self): def test_get_starred(self):
self._create_starred_info()
self._make_request("getStarred", tag="starred") self._make_request("getStarred", tag="starred")
self._make_request("getStarred", {"musicFolderId": 1}, tag="starred") self._make_request("getStarred", {"musicFolderId": 1}, tag="starred")
def test_get_starred2(self): def test_get_starred2(self):
self._create_starred_info()
self._make_request("getStarred2", tag="starred2") self._make_request("getStarred2", tag="starred2")
self._make_request("getStarred2", {"musicFolderId": 1}, tag="starred2") self._make_request("getStarred2", {"musicFolderId": 1}, tag="starred2")