2021-09-18 15:00:02 +00:00
|
|
|
# This file is part of Supysonic.
|
|
|
|
# Supysonic is a Python implementation of the Subsonic server API.
|
|
|
|
#
|
2022-12-31 16:17:49 +00:00
|
|
|
# Copyright (C) 2021-2022 Alban 'spl0k' Féron
|
2021-09-18 15:00:02 +00:00
|
|
|
#
|
|
|
|
# Distributed under terms of the GNU AGPLv3 license.
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from supysonic import db
|
|
|
|
|
|
|
|
|
|
|
|
class Issue221TestCase(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
db.init_database("sqlite:")
|
2022-12-31 16:17:49 +00:00
|
|
|
root = db.Folder.create(root=True, name="Folder", path="tests")
|
|
|
|
artist = db.Artist.create(name="Artist")
|
|
|
|
album = db.Album.create(artist=artist, name="Album")
|
|
|
|
|
|
|
|
for i in range(3):
|
|
|
|
db.Track.create(
|
|
|
|
title="Track {}".format(i),
|
|
|
|
album=album,
|
|
|
|
artist=artist,
|
|
|
|
disc=1,
|
|
|
|
number=i + 1,
|
|
|
|
duration=3,
|
|
|
|
has_art=False,
|
|
|
|
bitrate=64,
|
|
|
|
path="tests/track{}".format(i),
|
|
|
|
last_modification=2,
|
|
|
|
root_folder=root,
|
|
|
|
folder=root,
|
|
|
|
genre="Genre",
|
|
|
|
)
|
|
|
|
|
|
|
|
db.User.create(name="user", password="secret", salt="sugar")
|
2021-09-18 15:00:02 +00:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
db.release_database()
|
|
|
|
|
|
|
|
def test_issue(self):
|
|
|
|
data = db.Album.get().as_subsonic_album(db.User.get())
|
|
|
|
self.assertIn("genre", data)
|
|
|
|
self.assertEqual(data["genre"], "Genre")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|