Update tests (#384)

* Update tests

* Move comment regarding changing YT URLs to the appropriate assert
This commit is contained in:
Linus Groh
2018-10-02 12:13:21 +02:00
committed by Ritiek Malhotra
parent 6cb12722d0
commit 2725402ab3
7 changed files with 118 additions and 112 deletions

View File

@@ -1,28 +1,30 @@
from spotdl import spotify_tools
from spotdl import const
from spotdl import spotdl
import builtins
import os
from spotdl import spotify_tools
from spotdl import const
from spotdl import spotdl
PLAYLIST_URL = 'https://open.spotify.com/user/alex/playlist/0iWOVoumWlkXIrrBTSJmN8'
ALBUM_URL = 'https://open.spotify.com/album/499J8bIsEnU7DSrosFDJJg'
def test_user_playlists(tmpdir, monkeypatch):
expect_tracks = 14
text_file = os.path.join(str(tmpdir), 'test_us.txt')
monkeypatch.setattr('builtins.input', lambda x: 1)
spotify_tools.write_user_playlist('alex', text_file)
with open(text_file, 'r') as tin:
tracks = len(tin.readlines())
with open(text_file, 'r') as f:
tracks = len(f.readlines())
assert tracks == expect_tracks
def test_playlist(tmpdir):
expect_tracks = 14
text_file = os.path.join(str(tmpdir), 'test_pl.txt')
spotify_tools.write_playlist('https://open.spotify.com/user/alex/playlist/0iWOVoumWlkXIrrBTSJmN8', text_file)
with open(text_file, 'r') as tin:
tracks = len(tin.readlines())
spotify_tools.write_playlist(PLAYLIST_URL, text_file)
with open(text_file, 'r') as f:
tracks = len(f.readlines())
assert tracks == expect_tracks
@@ -30,9 +32,9 @@ def test_album(tmpdir):
expect_tracks = 15
global text_file
text_file = os.path.join(str(tmpdir), 'test_al.txt')
spotify_tools.write_album('https://open.spotify.com/album/499J8bIsEnU7DSrosFDJJg', text_file)
with open(text_file, 'r') as tin:
tracks = len(tin.readlines())
spotify_tools.write_album(ALBUM_URL, text_file)
with open(text_file, 'r') as f:
tracks = len(f.readlines())
assert tracks == expect_tracks
@@ -47,4 +49,4 @@ def test_trim():
with open(text_file, 'r') as track_file:
number = len(track_file.readlines())
assert (expect_number == number and expect_track == track)
assert expect_number == number and expect_track == track