From 8652c47ec388b37f3d07925fc4d26fbb53473477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alban=20F=C3=A9ron?= Date: Sat, 18 Sep 2021 17:00:02 +0200 Subject: [PATCH] Added test for #221 --- tests/__init__.py | 2 ++ tests/issue221.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 tests/issue221.py diff --git a/tests/__init__.py b/tests/__init__.py index 36ba151..3ea7952 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -19,6 +19,7 @@ from .issue129 import Issue129TestCase from .issue133 import Issue133TestCase from .issue139 import Issue139TestCase from .issue148 import Issue148TestCase +from .issue221 import Issue221TestCase def suite(): @@ -34,5 +35,6 @@ def suite(): suite.addTest(unittest.makeSuite(Issue133TestCase)) suite.addTest(unittest.makeSuite(Issue139TestCase)) suite.addTest(unittest.makeSuite(Issue148TestCase)) + suite.addTest(unittest.makeSuite(Issue221TestCase)) return suite diff --git a/tests/issue221.py b/tests/issue221.py new file mode 100755 index 0000000..2825d19 --- /dev/null +++ b/tests/issue221.py @@ -0,0 +1,53 @@ +# This file is part of Supysonic. +# Supysonic is a Python implementation of the Subsonic server API. +# +# Copyright (C) 2021 Alban 'spl0k' FĂ©ron +# +# Distributed under terms of the GNU AGPLv3 license. + +import unittest + +from pony.orm import db_session + +from supysonic import db + + +class Issue221TestCase(unittest.TestCase): + def setUp(self): + db.init_database("sqlite:") + with db_session: + root = db.Folder(root=True, name="Folder", path="tests") + artist = db.Artist(name="Artist") + album = db.Album(artist=artist, name="Album") + + for i in range(3): + db.Track( + 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(name="user", password="secret", salt="sugar") + + def tearDown(self): + db.release_database() + + @db_session + 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()