Skip to content

Commit

Permalink
Fix getting starred stuff
Browse files Browse the repository at this point in the history
Closes #246
  • Loading branch information
spl0k committed Feb 25, 2023
1 parent 245e9c7 commit 8e2adf8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
16 changes: 10 additions & 6 deletions supysonic/api/albums_songs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
},
)

Expand Down Expand Up @@ -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
],
},
)
23 changes: 22 additions & 1 deletion tests/api/test_album_songs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -260,11 +270,22 @@ def test_get_random_songs(self):
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")

Expand Down

0 comments on commit 8e2adf8

Please sign in to comment.