mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-10 04:02:17 +00:00
Fix independent tests
This commit is contained in:
parent
ee8165bb03
commit
e51abfe80f
@ -1,7 +1,7 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# 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.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
@ -10,8 +10,6 @@ import shutil
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pony.orm import db_session
|
|
||||||
|
|
||||||
from supysonic.db import init_database, release_database
|
from supysonic.db import init_database, release_database
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
from supysonic.scanner import Scanner
|
from supysonic.scanner import Scanner
|
||||||
@ -21,7 +19,6 @@ class Issue101TestCase(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.__dir = tempfile.mkdtemp()
|
self.__dir = tempfile.mkdtemp()
|
||||||
init_database("sqlite:")
|
init_database("sqlite:")
|
||||||
with db_session:
|
|
||||||
FolderManager.add("folder", self.__dir)
|
FolderManager.add("folder", self.__dir)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -37,14 +34,12 @@ class Issue101TestCase(unittest.TestCase):
|
|||||||
"tests/assets/folder/silence.mp3", os.path.join(subdir, "silence.mp3")
|
"tests/assets/folder/silence.mp3", os.path.join(subdir, "silence.mp3")
|
||||||
)
|
)
|
||||||
|
|
||||||
with db_session:
|
|
||||||
scanner = Scanner()
|
scanner = Scanner()
|
||||||
scanner.queue_folder("folder")
|
scanner.queue_folder("folder")
|
||||||
scanner.run()
|
scanner.run()
|
||||||
|
|
||||||
shutil.rmtree(firstsubdir)
|
shutil.rmtree(firstsubdir)
|
||||||
|
|
||||||
with db_session:
|
|
||||||
scanner = Scanner()
|
scanner = Scanner()
|
||||||
scanner.queue_folder("folder")
|
scanner.queue_folder("folder")
|
||||||
scanner.run()
|
scanner.run()
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# 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.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pony.orm import db_session
|
|
||||||
|
|
||||||
from supysonic.db import User, Track, StarredTrack, RatingTrack
|
from supysonic.db import User, Track, StarredTrack, RatingTrack
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
from supysonic.scanner import Scanner
|
from supysonic.scanner import Scanner
|
||||||
@ -21,7 +19,6 @@ class Issue129TestCase(TestBase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
with db_session:
|
|
||||||
FolderManager.add("folder", os.path.abspath("tests/assets/folder"))
|
FolderManager.add("folder", os.path.abspath("tests/assets/folder"))
|
||||||
scanner = Scanner()
|
scanner = Scanner()
|
||||||
scanner.queue_folder("folder")
|
scanner.queue_folder("folder")
|
||||||
@ -31,19 +28,17 @@ class Issue129TestCase(TestBase):
|
|||||||
self.userid = User.get(name="alice").id
|
self.userid = User.get(name="alice").id
|
||||||
|
|
||||||
def test_last_play(self):
|
def test_last_play(self):
|
||||||
with db_session:
|
user = User[self.userid]
|
||||||
User[self.userid].last_play = Track[self.trackid]
|
user.last_play = Track[self.trackid]
|
||||||
with db_session:
|
user.save()
|
||||||
FolderManager.delete_by_name("folder")
|
FolderManager.delete_by_name("folder")
|
||||||
|
|
||||||
def test_starred(self):
|
def test_starred(self):
|
||||||
with db_session:
|
StarredTrack.create(user=self.userid, starred=self.trackid)
|
||||||
StarredTrack(user=self.userid, starred=self.trackid)
|
|
||||||
FolderManager.delete_by_name("folder")
|
FolderManager.delete_by_name("folder")
|
||||||
|
|
||||||
def test_rating(self):
|
def test_rating(self):
|
||||||
with db_session:
|
RatingTrack.create(user=self.userid, rated=self.trackid, rating=5)
|
||||||
RatingTrack(user=self.userid, rated=self.trackid, rating=5)
|
|
||||||
FolderManager.delete_by_name("folder")
|
FolderManager.delete_by_name("folder")
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# 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.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
@ -9,8 +9,6 @@ import shutil
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pony.orm import db_session
|
|
||||||
|
|
||||||
from supysonic.db import init_database, release_database
|
from supysonic.db import init_database, release_database
|
||||||
from supysonic.db import Track
|
from supysonic.db import Track
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
@ -22,14 +20,12 @@ class Issue133TestCase(unittest.TestCase):
|
|||||||
self.__dir = tempfile.mkdtemp()
|
self.__dir = tempfile.mkdtemp()
|
||||||
shutil.copy("tests/assets/issue133.flac", self.__dir)
|
shutil.copy("tests/assets/issue133.flac", self.__dir)
|
||||||
init_database("sqlite:")
|
init_database("sqlite:")
|
||||||
with db_session:
|
|
||||||
FolderManager.add("folder", self.__dir)
|
FolderManager.add("folder", self.__dir)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
release_database()
|
release_database()
|
||||||
shutil.rmtree(self.__dir)
|
shutil.rmtree(self.__dir)
|
||||||
|
|
||||||
@db_session
|
|
||||||
def test_issue133(self):
|
def test_issue133(self):
|
||||||
scanner = Scanner()
|
scanner = Scanner()
|
||||||
scanner.queue_folder("folder")
|
scanner.queue_folder("folder")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# 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.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
@ -9,8 +9,6 @@ import shutil
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pony.orm import db_session
|
|
||||||
|
|
||||||
from supysonic.db import init_database, release_database
|
from supysonic.db import init_database, release_database
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
from supysonic.scanner import Scanner
|
from supysonic.scanner import Scanner
|
||||||
@ -20,14 +18,12 @@ class Issue139TestCase(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.__dir = tempfile.mkdtemp()
|
self.__dir = tempfile.mkdtemp()
|
||||||
init_database("sqlite:")
|
init_database("sqlite:")
|
||||||
with db_session:
|
|
||||||
FolderManager.add("folder", self.__dir)
|
FolderManager.add("folder", self.__dir)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
release_database()
|
release_database()
|
||||||
shutil.rmtree(self.__dir)
|
shutil.rmtree(self.__dir)
|
||||||
|
|
||||||
@db_session
|
|
||||||
def do_scan(self):
|
def do_scan(self):
|
||||||
scanner = Scanner()
|
scanner = Scanner()
|
||||||
scanner.queue_folder("folder")
|
scanner.queue_folder("folder")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# 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.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
@ -11,8 +11,6 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pony.orm import db_session
|
|
||||||
|
|
||||||
from supysonic.db import init_database, release_database
|
from supysonic.db import init_database, release_database
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
from supysonic.scanner import Scanner
|
from supysonic.scanner import Scanner
|
||||||
@ -23,7 +21,6 @@ class Issue148TestCase(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.__dir = tempfile.mkdtemp()
|
self.__dir = tempfile.mkdtemp()
|
||||||
init_database("sqlite:")
|
init_database("sqlite:")
|
||||||
with db_session:
|
|
||||||
FolderManager.add("folder", self.__dir)
|
FolderManager.add("folder", self.__dir)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
@ -1,27 +1,24 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# 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.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pony.orm import db_session
|
|
||||||
|
|
||||||
from supysonic import db
|
from supysonic import db
|
||||||
|
|
||||||
|
|
||||||
class Issue221TestCase(unittest.TestCase):
|
class Issue221TestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
db.init_database("sqlite:")
|
db.init_database("sqlite:")
|
||||||
with db_session:
|
root = db.Folder.create(root=True, name="Folder", path="tests")
|
||||||
root = db.Folder(root=True, name="Folder", path="tests")
|
artist = db.Artist.create(name="Artist")
|
||||||
artist = db.Artist(name="Artist")
|
album = db.Album.create(artist=artist, name="Album")
|
||||||
album = db.Album(artist=artist, name="Album")
|
|
||||||
|
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
db.Track(
|
db.Track.create(
|
||||||
title="Track {}".format(i),
|
title="Track {}".format(i),
|
||||||
album=album,
|
album=album,
|
||||||
artist=artist,
|
artist=artist,
|
||||||
@ -37,12 +34,11 @@ class Issue221TestCase(unittest.TestCase):
|
|||||||
genre="Genre",
|
genre="Genre",
|
||||||
)
|
)
|
||||||
|
|
||||||
db.User(name="user", password="secret", salt="sugar")
|
db.User.create(name="user", password="secret", salt="sugar")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
db.release_database()
|
db.release_database()
|
||||||
|
|
||||||
@db_session
|
|
||||||
def test_issue(self):
|
def test_issue(self):
|
||||||
data = db.Album.get().as_subsonic_album(db.User.get())
|
data = db.Album.get().as_subsonic_album(db.User.get())
|
||||||
self.assertIn("genre", data)
|
self.assertIn("genre", data)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# 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.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
@ -12,8 +12,6 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pony.orm import db_session
|
|
||||||
|
|
||||||
from supysonic.db import init_database, release_database
|
from supysonic.db import init_database, release_database
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
from supysonic.scanner import Scanner
|
from supysonic.scanner import Scanner
|
||||||
@ -26,7 +24,6 @@ class Issue85TestCase(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.__dir = tempfile.mkdtemp()
|
self.__dir = tempfile.mkdtemp()
|
||||||
init_database("sqlite:")
|
init_database("sqlite:")
|
||||||
with db_session:
|
|
||||||
FolderManager.add("folder", self.__dir)
|
FolderManager.add("folder", self.__dir)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -40,7 +37,6 @@ class Issue85TestCase(unittest.TestCase):
|
|||||||
os.path.join(self.__dir.encode(), b"\xe6", b"silence.mp3"),
|
os.path.join(self.__dir.encode(), b"\xe6", b"silence.mp3"),
|
||||||
)
|
)
|
||||||
|
|
||||||
with db_session:
|
|
||||||
scanner = Scanner()
|
scanner = Scanner()
|
||||||
scanner.queue_folder("folder")
|
scanner.queue_folder("folder")
|
||||||
scanner.run()
|
scanner.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user