mirror of
https://github.com/beetbox/beets.git
synced 2025-12-08 01:23:09 +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
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
from beets import config
|
|
||||||
from beets.library import Album, Item
|
from beets.library import Album, Item
|
||||||
from beets.test.helper import BeetsTestCase
|
from beets.test.helper import PluginTestCase
|
||||||
from beetsplug.importfeeds import ImportFeedsPlugin
|
from beetsplug.importfeeds import ImportFeedsPlugin
|
||||||
|
|
||||||
|
|
||||||
class ImportfeedsTestTest(BeetsTestCase):
|
class ImportFeedsTest(PluginTestCase):
|
||||||
|
plugin = "importfeeds"
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.importfeeds = ImportFeedsPlugin()
|
self.importfeeds = ImportFeedsPlugin()
|
||||||
self.feeds_dir = self.temp_dir_path / "importfeeds"
|
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):
|
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)
|
album = Album(album="album/name", id=1)
|
||||||
item_path = os.path.join("path", "to", "item")
|
item_path = os.path.join("path", "to", "item")
|
||||||
item = Item(title="song", album_id=1, path=item_path)
|
item = Item(title="song", album_id=1, path=item_path)
|
||||||
|
|
@ -30,8 +31,8 @@ class ImportfeedsTestTest(BeetsTestCase):
|
||||||
assert item_path in playlist.read()
|
assert item_path in playlist.read()
|
||||||
|
|
||||||
def test_playlist_in_subdir(self):
|
def test_playlist_in_subdir(self):
|
||||||
config["importfeeds"]["formats"] = "m3u"
|
self.config["importfeeds"]["formats"] = "m3u"
|
||||||
config["importfeeds"]["m3u_name"] = os.path.join(
|
self.config["importfeeds"]["m3u_name"] = os.path.join(
|
||||||
"subdir", "imported.m3u"
|
"subdir", "imported.m3u"
|
||||||
)
|
)
|
||||||
album = Album(album="album/name", id=1)
|
album = Album(album="album/name", id=1)
|
||||||
|
|
@ -41,14 +42,14 @@ class ImportfeedsTestTest(BeetsTestCase):
|
||||||
self.lib.add(item)
|
self.lib.add(item)
|
||||||
|
|
||||||
self.importfeeds.album_imported(self.lib, album)
|
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)
|
playlist_subdir = os.path.dirname(playlist)
|
||||||
assert os.path.isdir(playlist_subdir)
|
assert os.path.isdir(playlist_subdir)
|
||||||
assert os.path.isfile(playlist)
|
assert os.path.isfile(playlist)
|
||||||
|
|
||||||
def test_playlist_per_session(self):
|
def test_playlist_per_session(self):
|
||||||
config["importfeeds"]["formats"] = "m3u_session"
|
self.config["importfeeds"]["formats"] = "m3u_session"
|
||||||
config["importfeeds"]["m3u_name"] = "imports.m3u"
|
self.config["importfeeds"]["m3u_name"] = "imports.m3u"
|
||||||
album = Album(album="album/name", id=1)
|
album = Album(album="album/name", id=1)
|
||||||
item_path = os.path.join("path", "to", "item")
|
item_path = os.path.join("path", "to", "item")
|
||||||
item = Item(title="song", album_id=1, path=item_path)
|
item = Item(title="song", album_id=1, path=item_path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue