mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 00:46:18 +00:00
Fix independent tests
This commit is contained in:
parent
ee8165bb03
commit
e51abfe80f
@ -1,7 +1,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2018 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2018-2022 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
@ -10,8 +10,6 @@ import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import init_database, release_database
|
||||
from supysonic.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
@ -21,8 +19,7 @@ class Issue101TestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.__dir = tempfile.mkdtemp()
|
||||
init_database("sqlite:")
|
||||
with db_session:
|
||||
FolderManager.add("folder", self.__dir)
|
||||
FolderManager.add("folder", self.__dir)
|
||||
|
||||
def tearDown(self):
|
||||
release_database()
|
||||
@ -37,17 +34,15 @@ class Issue101TestCase(unittest.TestCase):
|
||||
"tests/assets/folder/silence.mp3", os.path.join(subdir, "silence.mp3")
|
||||
)
|
||||
|
||||
with db_session:
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
|
||||
shutil.rmtree(firstsubdir)
|
||||
|
||||
with db_session:
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,15 +1,13 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2018 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2018-2022 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
import os.path
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import User, Track, StarredTrack, RatingTrack
|
||||
from supysonic.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
@ -21,30 +19,27 @@ class Issue129TestCase(TestBase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
with db_session:
|
||||
FolderManager.add("folder", os.path.abspath("tests/assets/folder"))
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
FolderManager.add("folder", os.path.abspath("tests/assets/folder"))
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
|
||||
self.trackid = Track.select().first().id
|
||||
self.userid = User.get(name="alice").id
|
||||
self.trackid = Track.select().first().id
|
||||
self.userid = User.get(name="alice").id
|
||||
|
||||
def test_last_play(self):
|
||||
with db_session:
|
||||
User[self.userid].last_play = Track[self.trackid]
|
||||
with db_session:
|
||||
FolderManager.delete_by_name("folder")
|
||||
user = User[self.userid]
|
||||
user.last_play = Track[self.trackid]
|
||||
user.save()
|
||||
FolderManager.delete_by_name("folder")
|
||||
|
||||
def test_starred(self):
|
||||
with db_session:
|
||||
StarredTrack(user=self.userid, starred=self.trackid)
|
||||
FolderManager.delete_by_name("folder")
|
||||
StarredTrack.create(user=self.userid, starred=self.trackid)
|
||||
FolderManager.delete_by_name("folder")
|
||||
|
||||
def test_rating(self):
|
||||
with db_session:
|
||||
RatingTrack(user=self.userid, rated=self.trackid, rating=5)
|
||||
FolderManager.delete_by_name("folder")
|
||||
RatingTrack.create(user=self.userid, rated=self.trackid, rating=5)
|
||||
FolderManager.delete_by_name("folder")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2019 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2019-2022 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
@ -9,8 +9,6 @@ import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import init_database, release_database
|
||||
from supysonic.db import Track
|
||||
from supysonic.managers.folder import FolderManager
|
||||
@ -22,14 +20,12 @@ class Issue133TestCase(unittest.TestCase):
|
||||
self.__dir = tempfile.mkdtemp()
|
||||
shutil.copy("tests/assets/issue133.flac", self.__dir)
|
||||
init_database("sqlite:")
|
||||
with db_session:
|
||||
FolderManager.add("folder", self.__dir)
|
||||
FolderManager.add("folder", self.__dir)
|
||||
|
||||
def tearDown(self):
|
||||
release_database()
|
||||
shutil.rmtree(self.__dir)
|
||||
|
||||
@db_session
|
||||
def test_issue133(self):
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2019 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2019-2022 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
@ -9,8 +9,6 @@ import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import init_database, release_database
|
||||
from supysonic.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
@ -20,14 +18,12 @@ class Issue139TestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.__dir = tempfile.mkdtemp()
|
||||
init_database("sqlite:")
|
||||
with db_session:
|
||||
FolderManager.add("folder", self.__dir)
|
||||
FolderManager.add("folder", self.__dir)
|
||||
|
||||
def tearDown(self):
|
||||
release_database()
|
||||
shutil.rmtree(self.__dir)
|
||||
|
||||
@db_session
|
||||
def do_scan(self):
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2019-2020 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2019-2022 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
@ -11,8 +11,6 @@ import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import init_database, release_database
|
||||
from supysonic.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
@ -23,8 +21,7 @@ class Issue148TestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.__dir = tempfile.mkdtemp()
|
||||
init_database("sqlite:")
|
||||
with db_session:
|
||||
FolderManager.add("folder", self.__dir)
|
||||
FolderManager.add("folder", self.__dir)
|
||||
|
||||
def tearDown(self):
|
||||
release_database()
|
||||
|
@ -1,48 +1,44 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2021 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2021-2022 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")
|
||||
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(
|
||||
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",
|
||||
)
|
||||
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(name="user", password="secret", salt="sugar")
|
||||
db.User.create(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)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2020 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2020-2022 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
@ -12,8 +12,6 @@ import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import init_database, release_database
|
||||
from supysonic.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
@ -26,8 +24,7 @@ class Issue85TestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.__dir = tempfile.mkdtemp()
|
||||
init_database("sqlite:")
|
||||
with db_session:
|
||||
FolderManager.add("folder", self.__dir)
|
||||
FolderManager.add("folder", self.__dir)
|
||||
|
||||
def tearDown(self):
|
||||
release_database()
|
||||
@ -40,10 +37,9 @@ class Issue85TestCase(unittest.TestCase):
|
||||
os.path.join(self.__dir.encode(), b"\xe6", b"silence.mp3"),
|
||||
)
|
||||
|
||||
with db_session:
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user