-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathtest_m3u.py
More file actions
25 lines (19 loc) · 838 Bytes
/
test_m3u.py
File metadata and controls
25 lines (19 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pytest
from spotdl.types.playlist import Playlist
from spotdl.utils.m3u import create_m3u_content, create_m3u_file
PLAYLIST = "https://open.spotify.com/playlist/5LkNhFidYyyjRWwnkcMbQs"
def test_create_m3u_content():
playlist = Playlist.from_url(PLAYLIST)
content = create_m3u_content(
playlist.songs, "{title} - {output-ext}.{output-ext}", "mp3"
)
assert content != ""
assert len(content.split("\n")) > 5
assert content.split("\n")[0] == "#EXTM3U"
assert content.split("\n")[1].startswith("#EXTINF:")
assert content.split("\n")[2].endswith(".mp3")
def test_create_m3u_file(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
playlist = Playlist.from_url(PLAYLIST)
create_m3u_file("test.m3u", playlist.songs, "", "mp3")
assert tmp_path.join("test.m3u").isfile() is True