Cache songs on get playlist details

This commit is contained in:
Sumner Evans
2020-04-22 01:51:29 -06:00
parent c90b52f493
commit 934eff06c5
6 changed files with 79 additions and 13 deletions

View File

@@ -98,12 +98,27 @@ def test_caching_get_playlist_details(
# Ingest an empty list (for example, no playlists added yet to server).
cache_adapter.ingest_new_data(
FilesystemAdapter.FunctionNames.GET_PLAYLIST_DETAILS, ('1', ),
SubsonicAPI.PlaylistWithSongs('1', 'test1', songs=[]))
FilesystemAdapter.FunctionNames.GET_PLAYLIST_DETAILS,
('1', ),
SubsonicAPI.PlaylistWithSongs(
'1',
'test1',
songs=[
SubsonicAPI.Child(
'1', 'Song 1', duration=timedelta(seconds=10.2)),
SubsonicAPI.Child(
'2', 'Song 2', duration=timedelta(seconds=20.8)),
],
),
)
playlist = cache_adapter.get_playlist_details('1')
assert playlist.id == '1'
assert playlist.name == 'test1'
assert playlist.song_count == 2
assert playlist.duration == timedelta(seconds=31)
assert (playlist.songs[0].id, playlist.songs[0].title) == ('1', 'Song 1')
assert (playlist.songs[1].id, playlist.songs[1].title) == ('2', 'Song 2')
with pytest.raises(CacheMissError):
cache_adapter.get_playlist_details('2')