mirror of
https://github.com/beetbox/beets.git
synced 2026-01-17 05:34:23 +01:00
fixed/updated test to consider sanitized playlist names
This commit is contained in:
parent
3e53d4caff
commit
5942adba01
2 changed files with 12 additions and 9 deletions
|
|
@ -173,7 +173,8 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
|
||||
for playlist in self._matched_playlists:
|
||||
name, (query, q_sort), (album_query, a_q_sort) = playlist
|
||||
self._log.debug(u"Creating playlist {0}", name)
|
||||
sanitized_name = sanitize_path(name, lib.replacements)
|
||||
self._log.debug(u"Creating playlist {0}", sanitized_name)
|
||||
items = []
|
||||
|
||||
if query:
|
||||
|
|
@ -186,7 +187,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
# As we allow tags in the m3u names, we'll need to iterate through
|
||||
# the items and generate the correct m3u file names.
|
||||
for item in items:
|
||||
m3u_name = sanitize_path(item.evaluate_template(name, True), lib.replacements)
|
||||
m3u_name = item.evaluate_template(sanitized_name, True)
|
||||
if m3u_name not in m3us:
|
||||
m3us[m3u_name] = []
|
||||
item_path = item.path
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from beetsplug.smartplaylist import SmartPlaylistPlugin
|
|||
from beets.library import Item, Album, parse_query_string
|
||||
from beets.dbcore import OrQuery
|
||||
from beets.dbcore.query import NullSort, MultipleSort, FixedFieldSort
|
||||
from beets.util import syspath, bytestring_path, py3_path
|
||||
from beets.util import syspath, bytestring_path, py3_path, CHAR_REPLACE
|
||||
from beets.ui import UserError
|
||||
from beets import config
|
||||
|
||||
|
|
@ -151,12 +151,15 @@ class SmartPlaylistTest(unittest.TestCase):
|
|||
|
||||
i = Mock(path=b'/tagada.mp3')
|
||||
i.evaluate_template.side_effect = lambda x, _: x
|
||||
q = Mock()
|
||||
a_q = Mock()
|
||||
|
||||
lib = Mock()
|
||||
lib.replacements = CHAR_REPLACE
|
||||
lib.items.return_value = [i]
|
||||
lib.albums.return_value = []
|
||||
pl = b'my_playlist.m3u', (q, None), (a_q, None)
|
||||
|
||||
q = Mock()
|
||||
a_q = Mock()
|
||||
pl = b'.my:<playlist>.m3u', (q, None), (a_q, None)
|
||||
spl._matched_playlists = [pl]
|
||||
|
||||
dir = bytestring_path(mkdtemp())
|
||||
|
|
@ -171,15 +174,14 @@ class SmartPlaylistTest(unittest.TestCase):
|
|||
lib.items.assert_called_once_with(q, None)
|
||||
lib.albums.assert_called_once_with(a_q, None)
|
||||
|
||||
m3u_filepath = path.join(dir, pl[0])
|
||||
m3u_filepath = path.join(dir, b'_my__playlist_.m3u')
|
||||
self.assertTrue(path.exists(m3u_filepath))
|
||||
with open(syspath(m3u_filepath), 'rb') as f:
|
||||
content = f.read()
|
||||
rmtree(dir)
|
||||
|
||||
self.assertEqual(content, b'/tagada.mp3\n')
|
||||
|
||||
|
||||
|
||||
class SmartPlaylistCLITest(unittest.TestCase, TestHelper):
|
||||
def setUp(self):
|
||||
self.setup_beets()
|
||||
|
|
|
|||
Loading…
Reference in a new issue