2018-11-01 13:02:12 +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) 2018-2022 Alban 'spl0k' Féron
|
2018-11-01 13:02:12 +00:00
|
|
|
#
|
|
|
|
# Distributed under terms of the GNU AGPLv3 license.
|
|
|
|
|
|
|
|
import os.path
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from supysonic.db import User, Track, StarredTrack, RatingTrack
|
|
|
|
from supysonic.managers.folder import FolderManager
|
|
|
|
from supysonic.scanner import Scanner
|
|
|
|
|
|
|
|
from .testbase import TestBase
|
|
|
|
|
2019-06-29 15:25:44 +00:00
|
|
|
|
2018-11-01 13:02:12 +00:00
|
|
|
class Issue129TestCase(TestBase):
|
|
|
|
def setUp(self):
|
2020-11-22 15:12:14 +00:00
|
|
|
super().setUp()
|
2018-11-01 13:02:12 +00:00
|
|
|
|
2022-12-31 16:17:49 +00:00
|
|
|
FolderManager.add("folder", os.path.abspath("tests/assets/folder"))
|
|
|
|
scanner = Scanner()
|
|
|
|
scanner.queue_folder("folder")
|
|
|
|
scanner.run()
|
2018-11-01 13:02:12 +00:00
|
|
|
|
2022-12-31 16:17:49 +00:00
|
|
|
self.trackid = Track.select().first().id
|
|
|
|
self.userid = User.get(name="alice").id
|
2018-11-01 13:02:12 +00:00
|
|
|
|
|
|
|
def test_last_play(self):
|
2022-12-31 16:17:49 +00:00
|
|
|
user = User[self.userid]
|
|
|
|
user.last_play = Track[self.trackid]
|
|
|
|
user.save()
|
|
|
|
FolderManager.delete_by_name("folder")
|
2018-11-01 13:02:12 +00:00
|
|
|
|
|
|
|
def test_starred(self):
|
2022-12-31 16:17:49 +00:00
|
|
|
StarredTrack.create(user=self.userid, starred=self.trackid)
|
|
|
|
FolderManager.delete_by_name("folder")
|
2018-11-01 13:02:12 +00:00
|
|
|
|
|
|
|
def test_rating(self):
|
2022-12-31 16:17:49 +00:00
|
|
|
RatingTrack.create(user=self.userid, rated=self.trackid, rating=5)
|
|
|
|
FolderManager.delete_by_name("folder")
|
2018-11-01 13:02:12 +00:00
|
|
|
|
|
|
|
|
2019-06-29 15:25:44 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|