File: issue221.py

package info (click to toggle)
supysonic 0.7.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,716 kB
  • sloc: python: 9,315; sql: 1,029; sh: 25; makefile: 19; javascript: 6
file content (53 lines) | stat: -rw-r--r-- 1,491 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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()