Skip to content

Commit 394a6e0

Browse files
committed
smartplaylist: Fix existing tests after CLI overhaul
1 parent f3a915b commit 394a6e0

1 file changed

Lines changed: 16 additions & 19 deletions

File tree

test/plugins/test_smartplaylist.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# TODO: Tests in this fire are very bad. Stop using Mocks in this module.
1616

17-
from os import path, remove
17+
import os
1818
from pathlib import Path
1919
from shutil import rmtree
2020
from tempfile import mkdtemp
@@ -171,9 +171,9 @@ def test_playlist_update(self):
171171
spl = SmartPlaylistPlugin()
172172

173173
i = Mock(path=b"/tagada.mp3")
174-
i.evaluate_template.side_effect = lambda pl, _: pl.replace(
175-
b"$title", b"ta:ga:da"
176-
).decode()
174+
i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode(
175+
pl
176+
).replace("$title", "ta:ga:da")
177177

178178
lib = Mock()
179179
lib.replacements = CHAR_REPLACE
@@ -212,10 +212,9 @@ def test_playlist_update_output_extm3u(self):
212212
type(i).title = PropertyMock(return_value="fake title")
213213
type(i).length = PropertyMock(return_value=300.123)
214214
type(i).path = PropertyMock(return_value=b"/tagada.mp3")
215-
i.evaluate_template.side_effect = lambda pl, _: pl.replace(
216-
b"$title",
217-
b"ta:ga:da",
218-
).decode()
215+
i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode(
216+
pl
217+
).replace("$title", "ta:ga:da")
219218

220219
lib = Mock()
221220
lib.replacements = CHAR_REPLACE
@@ -262,10 +261,9 @@ def test_playlist_update_output_extm3u_fields(self):
262261
type(i).path = PropertyMock(return_value=b"/tagada.mp3")
263262
a = {"id": 456, "genres": ["Rock", "Pop"]}
264263
i.__getitem__.side_effect = a.__getitem__
265-
i.evaluate_template.side_effect = lambda pl, _: pl.replace(
266-
b"$title",
267-
b"ta:ga:da",
268-
).decode()
264+
i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode(
265+
pl
266+
).replace("$title", "ta:ga:da")
269267

270268
lib = Mock()
271269
lib.replacements = CHAR_REPLACE
@@ -308,9 +306,9 @@ def test_playlist_update_uri_format(self):
308306
i = MagicMock()
309307
type(i).id = PropertyMock(return_value=3)
310308
type(i).path = PropertyMock(return_value=b"/tagada.mp3")
311-
i.evaluate_template.side_effect = lambda pl, _: pl.replace(
312-
b"$title", b"ta:ga:da"
313-
).decode()
309+
i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode(
310+
pl
311+
).replace("$title", "ta:ga:da")
314312

315313
lib = Mock()
316314
lib.replacements = CHAR_REPLACE
@@ -471,10 +469,9 @@ def test_playlist_update_dest_regen(self):
471469
)
472470
# Set a path which would be equal to the one returned by `item.destination`.
473471
type(i).destination = PropertyMock(return_value=lambda: b"/tagada.mp3")
474-
i.evaluate_template.side_effect = lambda pl, _: pl.replace(
475-
b"$title",
476-
b"ta:ga:da",
477-
).decode()
472+
i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode(
473+
pl
474+
).replace("$title", "ta:ga:da")
478475

479476
lib = Mock()
480477
lib.replacements = CHAR_REPLACE

0 commit comments

Comments
 (0)