diff --git a/supysonic/api/__init__.py b/supysonic/api/__init__.py index ccee972..7662166 100644 --- a/supysonic/api/__init__.py +++ b/supysonic/api/__init__.py @@ -15,9 +15,10 @@ from flask import Blueprint from pony.orm import ObjectNotFound from pony.orm import commit +from ..db import ClientPrefs, Folder from ..managers.user import UserManager -from .exceptions import Unauthorized +from .exceptions import GenericError, Unauthorized from .formatters import JSONFormatter, JSONPFormatter, XMLFormatter api = Blueprint("api", __name__) diff --git a/supysonic/api/albums_songs.py b/supysonic/api/albums_songs.py index 822d249..469d60f 100644 --- a/supysonic/api/albums_songs.py +++ b/supysonic/api/albums_songs.py @@ -11,10 +11,8 @@ from pony.orm import select, desc, avg, max, min, count, between from ..db import ( Folder, - Artist, Album, Track, - RatingFolder, StarredFolder, StarredArtist, StarredAlbum, diff --git a/supysonic/api/annotation.py b/supysonic/api/annotation.py index dae6fd8..3d44876 100644 --- a/supysonic/api/annotation.py +++ b/supysonic/api/annotation.py @@ -5,15 +5,13 @@ # # Distributed under terms of the GNU AGPLv3 license. -import sys import time -import uuid from flask import current_app, request from pony.orm import delete from pony.orm import ObjectNotFound -from ..db import Track, Album, Artist, Folder, User +from ..db import Track, Album, Artist, Folder from ..db import StarredTrack, StarredAlbum, StarredArtist, StarredFolder from ..db import RatingTrack, RatingFolder from ..lastfm import LastFm @@ -22,10 +20,11 @@ from . import api, get_entity, get_entity_id from .exceptions import AggregateException, GenericError, MissingParameter, NotFound -def star_single(cls, eid): +def star_single(cls, starcls, eid): """Stars an entity :param cls: entity class, Folder, Artist, Album or Track + :param starcls: matching starred class, StarredFolder, StarredArtist, StarredAlbum or StarredTrack :param eid: id of the entity to star """ @@ -34,27 +33,24 @@ def star_single(cls, eid): except ObjectNotFound: raise NotFound("{} {}".format(cls.__name__, eid)) - starred_cls = getattr(sys.modules[__name__], "Starred" + cls.__name__) try: - starred_cls[request.user, eid] + starcls[request.user, eid] raise GenericError("{} {} already starred".format(cls.__name__, eid)) except ObjectNotFound: pass - starred_cls(user=request.user, starred=e) + starcls(user=request.user, starred=e) -def unstar_single(cls, eid): +def unstar_single(cls, starcls, eid): """Unstars an entity :param cls: entity class, Folder, Artist, Album or Track + :param starcls: matching starred class, StarredFolder, StarredArtist, StarredAlbum or StarredTrack :param eid: id of the entity to unstar """ - starred_cls = getattr(sys.modules[__name__], "Starred" + cls.__name__) - delete( - s for s in starred_cls if s.user.id == request.user.id and s.starred.id == eid - ) + delete(s for s in starcls if s.user.id == request.user.id and s.starred.id == eid) return None @@ -81,12 +77,12 @@ def handle_star_request(func): if tid is not None: try: - func(Track, tid) + func(Track, StarredTrack, tid) except Exception as e: err = e else: try: - func(Folder, fid) + func(Folder, StarredFolder, fid) except Exception as e: err = e @@ -96,14 +92,14 @@ def handle_star_request(func): for alId in albumId: alb_id = get_entity_id(Album, alId) try: - func(Album, alb_id) + func(Album, StarredAlbum, alb_id) except Exception as e: errors.append(e) for arId in artistId: art_id = get_entity_id(Artist, arId) try: - func(Artist, art_id) + func(Artist, StarredArtist, art_id) except Exception as e: errors.append(e) diff --git a/supysonic/api/browse.py b/supysonic/api/browse.py index bb47abf..728ea9b 100644 --- a/supysonic/api/browse.py +++ b/supysonic/api/browse.py @@ -7,7 +7,6 @@ import re import string -import uuid from flask import current_app, request from pony.orm import ObjectNotFound, select, count diff --git a/supysonic/api/chat.py b/supysonic/api/chat.py index f5faa7a..486ed8c 100644 --- a/supysonic/api/chat.py +++ b/supysonic/api/chat.py @@ -7,7 +7,7 @@ from flask import request -from ..db import ChatMessage, User +from ..db import ChatMessage from . import api diff --git a/supysonic/api/errors.py b/supysonic/api/errors.py index 7842524..7050b9e 100644 --- a/supysonic/api/errors.py +++ b/supysonic/api/errors.py @@ -5,7 +5,6 @@ # # Distributed under terms of the GNU AGPLv3 license. -from flask import current_app from pony.orm import rollback from pony.orm import ObjectNotFound from werkzeug.exceptions import BadRequestKeyError @@ -27,7 +26,7 @@ def key_error(e): @api.errorhandler(ObjectNotFound) -def not_found(e): +def object_not_found(e): rollback() return NotFound(e.entity.__name__) diff --git a/supysonic/api/media.py b/supysonic/api/media.py index dc9cc41..3271d31 100644 --- a/supysonic/api/media.py +++ b/supysonic/api/media.py @@ -7,7 +7,6 @@ # Distributed under terms of the GNU AGPLv3 license. import hashlib -import io import json import logging import mediafile @@ -16,7 +15,6 @@ import os.path import requests import shlex import subprocess -import uuid import zlib from flask import request, Response, send_file @@ -27,14 +25,12 @@ from xml.etree import ElementTree from zipfile import ZIP_DEFLATED from zipstream import ZipFile -from .. import scanner from ..cache import CacheMiss -from ..db import Track, Album, Artist, Folder, User, ClientPrefs, now +from ..db import Track, Album, Folder, now from . import api, get_entity, get_entity_id from .exceptions import ( GenericError, - MissingParameter, NotFound, ServerError, UnsupportedParameter, @@ -168,7 +164,7 @@ def stream_media(): yield data def kill_processes(): - if dec_proc != None: + if dec_proc is not None: dec_proc.kill() proc.kill() @@ -194,7 +190,7 @@ def stream_media(): kill_processes() raise finally: - if dec_proc != None: + if dec_proc is not None: dec_proc.stdout.close() dec_proc.wait() proc.stdout.close() diff --git a/supysonic/api/radio.py b/supysonic/api/radio.py index e035d75..4bb58d8 100644 --- a/supysonic/api/radio.py +++ b/supysonic/api/radio.py @@ -10,7 +10,7 @@ from flask import request from ..db import RadioStation from . import api, get_entity -from .exceptions import Forbidden, MissingParameter, NotFound +from .exceptions import Forbidden, MissingParameter @api.route("/getInternetRadioStations.view", methods=["GET", "POST"]) diff --git a/supysonic/api/user.py b/supysonic/api/user.py index 9c744a9..19546d1 100644 --- a/supysonic/api/user.py +++ b/supysonic/api/user.py @@ -12,7 +12,7 @@ from ..db import User from ..managers.user import UserManager from . import api, decode_password -from .exceptions import Forbidden, GenericError, NotFound +from .exceptions import Forbidden, NotFound def admin_only(f): diff --git a/supysonic/db.py b/supysonic/db.py index 2f81797..2fa3fa0 100644 --- a/supysonic/db.py +++ b/supysonic/db.py @@ -16,7 +16,7 @@ from hashlib import sha1 from pony.orm import Database, Required, Optional, Set, PrimaryKey, LongStr from pony.orm import ObjectNotFound, DatabaseError from pony.orm import buffer -from pony.orm import min, max, avg, sum, count, exists +from pony.orm import min, avg, sum, count, exists from pony.orm import db_session from urllib.parse import urlparse, parse_qsl from uuid import UUID, uuid4 diff --git a/supysonic/frontend/__init__.py b/supysonic/frontend/__init__.py index 1378c4c..27ad49c 100644 --- a/supysonic/frontend/__init__.py +++ b/supysonic/frontend/__init__.py @@ -6,7 +6,15 @@ # # Distributed under terms of the GNU AGPLv3 license. -from flask import current_app, redirect, request, session, url_for +from flask import ( + current_app, + flash, + redirect, + request, + render_template, + session, + url_for, +) from flask import Blueprint from functools import wraps from pony.orm import ObjectNotFound diff --git a/supysonic/frontend/user.py b/supysonic/frontend/user.py index 8e57a75..f215028 100644 --- a/supysonic/frontend/user.py +++ b/supysonic/frontend/user.py @@ -12,7 +12,7 @@ from flask import current_app from functools import wraps from pony.orm import ObjectNotFound -from ..db import User, ClientPrefs +from ..db import User from ..lastfm import LastFm from ..managers.user import UserManager diff --git a/supysonic/managers/folder.py b/supysonic/managers/folder.py index 84573db..2d6930f 100644 --- a/supysonic/managers/folder.py +++ b/supysonic/managers/folder.py @@ -6,7 +6,6 @@ # Distributed under terms of the GNU AGPLv3 license. import os.path -import uuid from pony.orm import select from pony.orm import ObjectNotFound diff --git a/supysonic/scanner.py b/supysonic/scanner.py index f56ff88..b9ad35a 100644 --- a/supysonic/scanner.py +++ b/supysonic/scanner.py @@ -6,7 +6,8 @@ # Distributed under terms of the GNU AGPLv3 license. import logging -import os, os.path +import os +import os.path import mediafile import time @@ -16,9 +17,7 @@ from queue import Queue, Empty as QueueEmpty from threading import Thread, Event from .covers import find_cover_in_folder, CoverFile -from .db import Folder, Artist, Album, Track, User -from .db import StarredFolder, StarredArtist, StarredAlbum, StarredTrack -from .db import RatingFolder, RatingTrack +from .db import Folder, Artist, Album, Track logger = logging.getLogger(__name__) @@ -212,7 +211,6 @@ class Scanner(Thread): return mtime = int(stat.st_mtime) - size = stat.st_size tr = Track.get(path=path) if tr is not None: diff --git a/supysonic/schema/migration/mysql/20171230.py b/supysonic/schema/migration/mysql/20171230.py index aece82b..39e8c24 100644 --- a/supysonic/schema/migration/mysql/20171230.py +++ b/supysonic/schema/migration/mysql/20171230.py @@ -32,7 +32,7 @@ def process_table(connection, table, fields, nullable_fields=()): c.execute("SELECT {1} FROM {0}".format(table, ",".join(fields + nullable_fields))) for row in c: for field, value in zip(fields + nullable_fields, row): - if value is None or not isinstance(value, basestring): + if value is None or not isinstance(value, str): continue to_update[field].add(value) diff --git a/supysonic/schema/migration/postgres/20180317.py b/supysonic/schema/migration/postgres/20180317.py index 5f9216f..5719f77 100644 --- a/supysonic/schema/migration/postgres/20180317.py +++ b/supysonic/schema/migration/postgres/20180317.py @@ -1,7 +1,6 @@ import argparse import hashlib import psycopg2 -import uuid try: bytes = buffer diff --git a/supysonic/schema/migration/sqlite/20171230.py b/supysonic/schema/migration/sqlite/20171230.py index 6f48054..0251e6c 100644 --- a/supysonic/schema/migration/sqlite/20171230.py +++ b/supysonic/schema/migration/sqlite/20171230.py @@ -23,13 +23,13 @@ def process_table(connection, table, fields): c = connection.cursor() for row in c.execute("SELECT {1} FROM {0}".format(table, ",".join(fields))): for field, value in zip(fields, row): - if value is None or not isinstance(value, basestring): + if value is None or not isinstance(value, str): continue to_update[field].add(value) for field, values in to_update.iteritems(): sql = "UPDATE {0} SET {1}=? WHERE {1}=?".format(table, field) - c.executemany(sql, map(lambda v: (buffer(UUID(v).bytes), v), values)) + c.executemany(sql, map(lambda v: (UUID(v).bytes, v), values)) connection.commit() diff --git a/supysonic/schema/migration/sqlite/20180317.py b/supysonic/schema/migration/sqlite/20180317.py index 5888cc9..485c387 100644 --- a/supysonic/schema/migration/sqlite/20180317.py +++ b/supysonic/schema/migration/sqlite/20180317.py @@ -1,7 +1,6 @@ import argparse import hashlib import sqlite3 -import uuid try: bytes = buffer diff --git a/supysonic/web.py b/supysonic/web.py index 2d05149..9a128c9 100644 --- a/supysonic/web.py +++ b/supysonic/web.py @@ -7,7 +7,6 @@ # # Distributed under terms of the GNU AGPLv3 license. -import io import logging import mimetypes diff --git a/tests/api/apitestbase.py b/tests/api/apitestbase.py index 46ad906..6f9ab50 100644 --- a/tests/api/apitestbase.py +++ b/tests/api/apitestbase.py @@ -8,7 +8,6 @@ import re from lxml import etree -from supysonic.managers.user import UserManager from ..testbase import TestBase diff --git a/tests/api/test_album_songs.py b/tests/api/test_album_songs.py index a94fec8..c5da99b 100644 --- a/tests/api/test_album_songs.py +++ b/tests/api/test_album_songs.py @@ -5,7 +5,7 @@ # # Distributed under terms of the GNU AGPLv3 license. -import uuid +import unittest from pony.orm import db_session diff --git a/tests/api/test_annotation.py b/tests/api/test_annotation.py index 90e7481..07b96e7 100644 --- a/tests/api/test_annotation.py +++ b/tests/api/test_annotation.py @@ -5,6 +5,7 @@ # # Distributed under terms of the GNU AGPLv3 license. +import unittest import uuid from pony.orm import db_session diff --git a/tests/api/test_api_setup.py b/tests/api/test_api_setup.py index 78ba4e1..a7b8577 100644 --- a/tests/api/test_api_setup.py +++ b/tests/api/test_api_setup.py @@ -8,6 +8,7 @@ import base64 import flask.json +import unittest from xml.etree import ElementTree diff --git a/tests/api/test_browse.py b/tests/api/test_browse.py index b7021e3..c976f6f 100644 --- a/tests/api/test_browse.py +++ b/tests/api/test_browse.py @@ -6,9 +6,9 @@ # Distributed under terms of the GNU AGPLv3 license. import time +import unittest import uuid -from lxml import etree from pony.orm import db_session from supysonic.db import Folder, Artist, Album, Track @@ -43,7 +43,7 @@ class BrowseTestCase(ApiTestBase): album = Album(name=letter + lether + "lbum", artist=artist) for num, song in enumerate(["One", "Two", "Three"]): - track = Track( + Track( disc=1, number=num, title=song, diff --git a/tests/api/test_lyrics.py b/tests/api/test_lyrics.py index a66829c..abbd0e3 100644 --- a/tests/api/test_lyrics.py +++ b/tests/api/test_lyrics.py @@ -8,6 +8,7 @@ import flask.json import os.path import requests +import unittest from pony.orm import db_session @@ -32,7 +33,7 @@ class LyricsTestCase(ApiTestBase): artist = Artist(name="Artist") album = Album(artist=artist, name="Album") - track = Track( + Track( title="23bytes", number=1, disc=1, diff --git a/tests/api/test_media.py b/tests/api/test_media.py index 819f935..6c16ef4 100644 --- a/tests/api/test_media.py +++ b/tests/api/test_media.py @@ -6,6 +6,7 @@ # Distributed under terms of the GNU AGPLv3 license. import os.path +import unittest import uuid from contextlib import closing diff --git a/tests/api/test_playlist.py b/tests/api/test_playlist.py index 3eee60a..c040ef9 100644 --- a/tests/api/test_playlist.py +++ b/tests/api/test_playlist.py @@ -5,6 +5,7 @@ # # Distributed under terms of the GNU AGPLv3 license. +import unittest import uuid from pony.orm import db_session diff --git a/tests/api/test_response_helper.py b/tests/api/test_response_helper.py index ce59c51..78b0b54 100644 --- a/tests/api/test_response_helper.py +++ b/tests/api/test_response_helper.py @@ -87,18 +87,18 @@ class ResponseHelperJsonTestCase(TestBase, UnwrapperMixin.create_from(JSONFormat self.assertIn("dict", resp) self.assertIn("list", resp) - d = resp["dict"] - l = resp["list"] + dct = resp["dict"] + lst = resp["list"] - self.assertIn("value", d) - self.assertIn("list", d) - self.assertNotIn("emptyList", d) - self.assertIn("subdict", d) - self.assertIsInstance(d["value"], str) - self.assertIsInstance(d["list"], list) - self.assertIsInstance(d["subdict"], dict) + self.assertIn("value", dct) + self.assertIn("list", dct) + self.assertNotIn("emptyList", dct) + self.assertIn("subdict", dct) + self.assertIsInstance(dct["value"], str) + self.assertIsInstance(dct["list"], list) + self.assertIsInstance(dct["subdict"], dict) - self.assertEqual(l, [{"b": "B"}, {"c": "C"}, [4, 5, 6], "final string"]) + self.assertEqual(lst, [{"b": "B"}, {"c": "C"}, [4, 5, 6], "final string"]) class ResponseHelperJsonpTestCase(TestBase, UnwrapperMixin.create_from(JSONPFormatter)): diff --git a/tests/api/test_search.py b/tests/api/test_search.py index 316fab3..77bece2 100644 --- a/tests/api/test_search.py +++ b/tests/api/test_search.py @@ -40,7 +40,7 @@ class SearchTestCase(ApiTestBase): album = Album(name=letter + lether + "lbum", artist=artist) for num, song in enumerate(["One", "Two", "Three"]): - track = Track( + Track( disc=1, number=num, title=song, diff --git a/tests/api/test_system.py b/tests/api/test_system.py index 7281cdc..4a8bfb5 100644 --- a/tests/api/test_system.py +++ b/tests/api/test_system.py @@ -6,6 +6,8 @@ # # Distributed under terms of the GNU AGPLv3 license. +import unittest + from .apitestbase import ApiTestBase diff --git a/tests/api/test_transcoding.py b/tests/api/test_transcoding.py index f7690bc..ec131fb 100644 --- a/tests/api/test_transcoding.py +++ b/tests/api/test_transcoding.py @@ -11,7 +11,7 @@ import sys from flask import current_app from pony.orm import db_session -from supysonic.db import Folder, Track +from supysonic.db import Track from supysonic.managers.folder import FolderManager from supysonic.scanner import Scanner @@ -23,7 +23,7 @@ class TranscodingTestCase(ApiTestBase): super().setUp() with db_session: - folder = FolderManager.add("Folder", "tests/assets/folder") + FolderManager.add("Folder", "tests/assets/folder") scanner = Scanner() scanner.queue_folder("Folder") scanner.run() diff --git a/tests/api/test_user.py b/tests/api/test_user.py index 9c20481..e263cd0 100644 --- a/tests/api/test_user.py +++ b/tests/api/test_user.py @@ -6,6 +6,8 @@ # # Distributed under terms of the GNU AGPLv3 license. +import unittest + from ..utils import hexlify from .apitestbase import ApiTestBase diff --git a/tests/base/test_db.py b/tests/base/test_db.py index ecb91f2..9fd5d09 100644 --- a/tests/base/test_db.py +++ b/tests/base/test_db.py @@ -32,7 +32,7 @@ class DbTestCase(unittest.TestCase): def create_some_folders(self): root_folder = db.Folder(root=True, name="Root folder", path="tests") - child_folder = db.Folder( + db.Folder( root=False, name="Child folder", path="tests/assets", @@ -40,7 +40,7 @@ class DbTestCase(unittest.TestCase): parent=root_folder, ) - child_2 = db.Folder( + db.Folder( root=False, name="Child folder (No Art)", path="tests/formats", @@ -158,10 +158,10 @@ class DbTestCase(unittest.TestCase): root_folder, child_folder, _ = self.create_some_folders() user = self.create_user() - star = db.StarredFolder(user=user, starred=root_folder) - rating_user = db.RatingFolder(user=user, rated=root_folder, rating=2) + db.StarredFolder(user=user, starred=root_folder) + db.RatingFolder(user=user, rated=root_folder, rating=2) other = self.create_user("Other") - rating_other = db.RatingFolder(user=other, rated=root_folder, rating=5) + db.RatingFolder(user=other, rated=root_folder, rating=5) root = root_folder.as_subsonic_child(user) self.assertIn("starred", root) @@ -180,7 +180,7 @@ class DbTestCase(unittest.TestCase): artist = db.Artist(name="Test Artist") user = self.create_user() - star = db.StarredArtist(user=user, starred=artist) + db.StarredArtist(user=user, starred=artist) artist_dict = artist.as_subsonic_artist(user) self.assertIsInstance(artist_dict, dict) @@ -204,7 +204,7 @@ class DbTestCase(unittest.TestCase): album = db.Album(artist=artist, name="Test Album") user = self.create_user() - star = db.StarredAlbum(user=user, starred=album) + db.StarredAlbum(user=user, starred=album) # No tracks, shouldn't be stored under normal circumstances self.assertRaises(ValueError, album.as_subsonic_album, user) diff --git a/tests/base/test_scanner.py b/tests/base/test_scanner.py index 393df1c..feb3496 100644 --- a/tests/base/test_scanner.py +++ b/tests/base/test_scanner.py @@ -5,7 +5,6 @@ # # Distributed under terms of the GNU AGPLv3 license. -import io import mutagen import os import os.path @@ -131,8 +130,6 @@ class ScannerTestCase(unittest.TestCase): @db_session def test_rescan_corrupt_file(self): - track = db.Track.select().first() - with self.__temporary_track_copy() as tf: self.__scan() self.assertEqual(db.Track.select().count(), 2) @@ -147,8 +144,6 @@ class ScannerTestCase(unittest.TestCase): @db_session def test_rescan_removed_file(self): - track = db.Track.select().first() - with self.__temporary_track_copy(): self.__scan() self.assertEqual(db.Track.select().count(), 2) @@ -158,8 +153,6 @@ class ScannerTestCase(unittest.TestCase): @db_session def test_scan_tag_change(self): - folder = db.Folder[self.folderid] - with self.__temporary_track_copy() as tf: self.__scan() copy = db.Track.get(path=tf) diff --git a/tests/base/test_watcher.py b/tests/base/test_watcher.py index 2bfa2c3..7720d5f 100644 --- a/tests/base/test_watcher.py +++ b/tests/base/test_watcher.py @@ -277,7 +277,7 @@ class CoverWatcherTestCase(WatcherTestCase): self.assertIsNone(Folder.select().first().cover_art) def test_naming_add_good(self): - bad = os.path.basename(self._addcover()) + self._addcover() self._sleep() good = os.path.basename(self._addcover("cover")) self._sleep() @@ -288,7 +288,7 @@ class CoverWatcherTestCase(WatcherTestCase): def test_naming_add_bad(self): good = os.path.basename(self._addcover("cover")) self._sleep() - bad = os.path.basename(self._addcover()) + self._addcover() self._sleep() with db_session: diff --git a/tests/frontend/test_folder.py b/tests/frontend/test_folder.py index 2af7514..ce6a96a 100644 --- a/tests/frontend/test_folder.py +++ b/tests/frontend/test_folder.py @@ -5,7 +5,7 @@ # # Distributed under terms of the GNU AGPLv3 license. -import uuid +import unittest from pony.orm import db_session diff --git a/tests/frontend/test_login.py b/tests/frontend/test_login.py index 5691562..2a3853b 100644 --- a/tests/frontend/test_login.py +++ b/tests/frontend/test_login.py @@ -6,6 +6,7 @@ # # Distributed under terms of the GNU AGPLv3 license. +import unittest import uuid from pony.orm import db_session diff --git a/tests/frontend/test_playlist.py b/tests/frontend/test_playlist.py index 6a1b12c..da3d96a 100644 --- a/tests/frontend/test_playlist.py +++ b/tests/frontend/test_playlist.py @@ -5,6 +5,7 @@ # # Distributed under terms of the GNU AGPLv3 license. +import unittest import uuid from pony.orm import db_session diff --git a/tests/frontend/test_user.py b/tests/frontend/test_user.py index 2d30a69..9b759f8 100644 --- a/tests/frontend/test_user.py +++ b/tests/frontend/test_user.py @@ -5,6 +5,7 @@ # # Distributed under terms of the GNU AGPLv3 license. +import unittest import uuid from flask import escape diff --git a/tests/issue101.py b/tests/issue101.py index d7ce8ca..0801a98 100644 --- a/tests/issue101.py +++ b/tests/issue101.py @@ -13,7 +13,6 @@ import unittest from pony.orm import db_session from supysonic.db import init_database, release_database -from supysonic.db import Folder from supysonic.managers.folder import FolderManager from supysonic.scanner import Scanner diff --git a/tests/issue129.py b/tests/issue129.py index 2db00a6..dbc6ace 100644 --- a/tests/issue129.py +++ b/tests/issue129.py @@ -22,7 +22,7 @@ class Issue129TestCase(TestBase): super().setUp() with db_session: - folder = FolderManager.add("folder", os.path.abspath("tests/assets/folder")) + FolderManager.add("folder", os.path.abspath("tests/assets/folder")) scanner = Scanner() scanner.queue_folder("folder") scanner.run() diff --git a/tests/issue133.py b/tests/issue133.py index 7c77619..11ff762 100644 --- a/tests/issue133.py +++ b/tests/issue133.py @@ -12,7 +12,7 @@ import unittest from pony.orm import db_session from supysonic.db import init_database, release_database -from supysonic.db import Folder, Track +from supysonic.db import Track from supysonic.managers.folder import FolderManager from supysonic.scanner import Scanner diff --git a/tests/issue139.py b/tests/issue139.py index 46fcead..d9f2c66 100644 --- a/tests/issue139.py +++ b/tests/issue139.py @@ -12,7 +12,6 @@ import unittest from pony.orm import db_session from supysonic.db import init_database, release_database -from supysonic.db import Folder, Track from supysonic.managers.folder import FolderManager from supysonic.scanner import Scanner diff --git a/tests/issue148.py b/tests/issue148.py index d6a3dcf..f5eba7a 100644 --- a/tests/issue148.py +++ b/tests/issue148.py @@ -14,7 +14,6 @@ import unittest from pony.orm import db_session from supysonic.db import init_database, release_database -from supysonic.db import Folder from supysonic.managers.folder import FolderManager from supysonic.scanner import Scanner diff --git a/tests/managers/test_manager_folder.py b/tests/managers/test_manager_folder.py index 4397557..b9e86ed 100644 --- a/tests/managers/test_manager_folder.py +++ b/tests/managers/test_manager_folder.py @@ -13,7 +13,6 @@ import os import shutil import tempfile import unittest -import uuid from pony.orm import db_session, ObjectNotFound @@ -37,7 +36,7 @@ class FolderManagerTestCase(unittest.TestCase): self.assertIsNotNone(FolderManager.add("media", self.media_dir)) self.assertIsNotNone(FolderManager.add("music", self.music_dir)) - folder = db.Folder( + db.Folder( root=False, name="non-root", path=os.path.join(self.music_dir, "subfolder") ) @@ -45,7 +44,7 @@ class FolderManagerTestCase(unittest.TestCase): album = db.Album(name="Album", artist=artist) root = db.Folder.get(name="media") - track = db.Track( + db.Track( title="Track", artist=artist, album=album, diff --git a/tests/managers/test_manager_user.py b/tests/managers/test_manager_user.py index 798ca2a..3b5d1fa 100644 --- a/tests/managers/test_manager_user.py +++ b/tests/managers/test_manager_user.py @@ -9,7 +9,6 @@ from supysonic import db from supysonic.managers.user import UserManager -import io import unittest import uuid