1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 08:56: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(
"starred",
{
"artist": [sf.as_subsonic_artist(request.user) for sf in arq],
"album": [sf.as_subsonic_child(request.user) for sf in alq],
"song": [st.as_subsonic_child(request.user, request.client) for st in trq],
"artist": [sf.starred.as_subsonic_artist(request.user) for sf in arq],
"album": [sf.starred.as_subsonic_child(request.user) for sf in alq],
"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(
"starred2",
{
"artist": [sa.as_subsonic_artist(request.user) for sa in arq],
"album": [sa.as_subsonic_album(request.user) for sa in alq],
"song": [st.as_subsonic_child(request.user, request.client) for st in trq],
"artist": [sa.starred.as_subsonic_artist(request.user) for sa in arq],
"album": [sa.starred.as_subsonic_album(request.user) for sa in alq],
"song": [
st.starred.as_subsonic_child(request.user, request.client) for st in trq
],
},
)

View File

@ -7,7 +7,17 @@
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
@ -260,11 +270,22 @@ class AlbumSongsTestCase(ApiTestBase):
def test_now_playing(self):
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):
self._create_starred_info()
self._make_request("getStarred", tag="starred")
self._make_request("getStarred", {"musicFolderId": 1}, tag="starred")
def test_get_starred2(self):
self._create_starred_info()
self._make_request("getStarred2", tag="starred2")
self._make_request("getStarred2", {"musicFolderId": 1}, tag="starred2")