mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 19:52:16 +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,7 +19,6 @@ class Issue101TestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.__dir = tempfile.mkdtemp()
|
||||
init_database("sqlite:")
|
||||
with db_session:
|
||||
FolderManager.add("folder", self.__dir)
|
||||
|
||||
def tearDown(self):
|
||||
@ -37,14 +34,12 @@ 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()
|
||||
|
||||
shutil.rmtree(firstsubdir)
|
||||
|
||||
with db_session:
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
|
@ -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,7 +19,6 @@ 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")
|
||||
@ -31,19 +28,17 @@ class Issue129TestCase(TestBase):
|
||||
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:
|
||||
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)
|
||||
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)
|
||||
RatingTrack.create(user=self.userid, rated=self.trackid, rating=5)
|
||||
FolderManager.delete_by_name("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.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)
|
||||
|
||||
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)
|
||||
|
||||
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,7 +21,6 @@ class Issue148TestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.__dir = tempfile.mkdtemp()
|
||||
init_database("sqlite:")
|
||||
with db_session:
|
||||
FolderManager.add("folder", self.__dir)
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -1,27 +1,24 @@
|
||||
# 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(
|
||||
db.Track.create(
|
||||
title="Track {}".format(i),
|
||||
album=album,
|
||||
artist=artist,
|
||||
@ -37,12 +34,11 @@ class Issue221TestCase(unittest.TestCase):
|
||||
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,7 +24,6 @@ class Issue85TestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.__dir = tempfile.mkdtemp()
|
||||
init_database("sqlite:")
|
||||
with db_session:
|
||||
FolderManager.add("folder", self.__dir)
|
||||
|
||||
def tearDown(self):
|
||||
@ -40,7 +37,6 @@ 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()
|
||||
|
Loading…
Reference in New Issue
Block a user