mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 00:24:25 +01:00
importfeeds: Fix tests
- Use self.config instead of global config, which was interfering whith other plugin tests (test_importsource) when run alongside (eg in CI) - Rename test
This commit is contained in:
parent
e181ebeaae
commit
02a662e923
1 changed files with 11 additions and 10 deletions
|
|
@ -2,21 +2,22 @@ import datetime
|
|||
import os
|
||||
import os.path
|
||||
|
||||
from beets import config
|
||||
from beets.library import Album, Item
|
||||
from beets.test.helper import BeetsTestCase
|
||||
from beets.test.helper import PluginTestCase
|
||||
from beetsplug.importfeeds import ImportFeedsPlugin
|
||||
|
||||
|
||||
class ImportfeedsTestTest(BeetsTestCase):
|
||||
class ImportFeedsTest(PluginTestCase):
|
||||
plugin = "importfeeds"
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.importfeeds = ImportFeedsPlugin()
|
||||
self.feeds_dir = self.temp_dir_path / "importfeeds"
|
||||
config["importfeeds"]["dir"] = str(self.feeds_dir)
|
||||
self.config["importfeeds"]["dir"] = str(self.feeds_dir)
|
||||
|
||||
def test_multi_format_album_playlist(self):
|
||||
config["importfeeds"]["formats"] = "m3u_multi"
|
||||
self.config["importfeeds"]["formats"] = "m3u_multi"
|
||||
album = Album(album="album/name", id=1)
|
||||
item_path = os.path.join("path", "to", "item")
|
||||
item = Item(title="song", album_id=1, path=item_path)
|
||||
|
|
@ -30,8 +31,8 @@ class ImportfeedsTestTest(BeetsTestCase):
|
|||
assert item_path in playlist.read()
|
||||
|
||||
def test_playlist_in_subdir(self):
|
||||
config["importfeeds"]["formats"] = "m3u"
|
||||
config["importfeeds"]["m3u_name"] = os.path.join(
|
||||
self.config["importfeeds"]["formats"] = "m3u"
|
||||
self.config["importfeeds"]["m3u_name"] = os.path.join(
|
||||
"subdir", "imported.m3u"
|
||||
)
|
||||
album = Album(album="album/name", id=1)
|
||||
|
|
@ -41,14 +42,14 @@ class ImportfeedsTestTest(BeetsTestCase):
|
|||
self.lib.add(item)
|
||||
|
||||
self.importfeeds.album_imported(self.lib, album)
|
||||
playlist = self.feeds_dir / config["importfeeds"]["m3u_name"].get()
|
||||
playlist = self.feeds_dir / self.config["importfeeds"]["m3u_name"].get()
|
||||
playlist_subdir = os.path.dirname(playlist)
|
||||
assert os.path.isdir(playlist_subdir)
|
||||
assert os.path.isfile(playlist)
|
||||
|
||||
def test_playlist_per_session(self):
|
||||
config["importfeeds"]["formats"] = "m3u_session"
|
||||
config["importfeeds"]["m3u_name"] = "imports.m3u"
|
||||
self.config["importfeeds"]["formats"] = "m3u_session"
|
||||
self.config["importfeeds"]["m3u_name"] = "imports.m3u"
|
||||
album = Album(album="album/name", id=1)
|
||||
item_path = os.path.join("path", "to", "item")
|
||||
item = Item(title="song", album_id=1, path=item_path)
|
||||
|
|
|
|||
Loading…
Reference in a new issue