1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-09 11:42:16 +00:00
supysonic/tests/issue85.py
Alban Féron 5c46c96b53
Some fixes for Windows support (especially for tests)
The main motive here isn't full Windows support per, but being
able to run tests on Windows, as this is my main platform.
Booting a VM just to run tests is cumbersome.
2020-11-08 15:39:09 +01:00

51 lines
1.3 KiB
Python

# This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API.
#
# Copyright (C) 2020 Alban 'spl0k' Féron
#
# Distributed under terms of the GNU AGPLv3 license.
import os
import os.path
import shutil
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
@unittest.skipIf(
sys.platform == "win32", "Windows doesn't seem too allow badly encoded paths"
)
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):
release_database()
shutil.rmtree(self.__dir)
def test_issue(self):
os.mkdir(os.path.join(self.__dir.encode(), b"\xe6"))
shutil.copyfile(
"tests/assets/folder/silence.mp3",
os.path.join(self.__dir.encode(), b"\xe6", b"silence.mp3"),
)
with db_session:
scanner = Scanner()
scanner.queue_folder("folder")
scanner.run()
if __name__ == "__main__":
unittest.main()