mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-12-08 20:39:08 +00:00
Apply most best practices of PEP 8
This refactoring includes:
- Two empty lines before each global function
- Using '{0} {1}'.format(str1, str2) instead of str1 + ' ' + str2
Sometimes this will make lines longer, sometimes shorter.
- Starting all comments with # + space + comment
- Make lines not longer than 80 characters in most cases
- Renaming some variables to make more sense
- Add some missing code like returns and Exceptions
Not included, but follows:
- Make some comments docstrings
- Rename all 'file' variables, only for Python 2
- Remove some way too verbose comments ;)
This commit is contained in:
@@ -4,22 +4,26 @@ import spotdl
|
||||
|
||||
raw_song = 'http://open.spotify.com/track/0JlS7BXXD07hRmevDnbPDU'
|
||||
|
||||
|
||||
def test_spotify_title():
|
||||
expect_title = 'David André Østby - Intro'
|
||||
title = spotdl.generate_songname(raw_song)
|
||||
assert title == expect_title
|
||||
|
||||
|
||||
def test_youtube_url():
|
||||
expect_url = 'youtube.com/watch?v=rg1wfcty0BA'
|
||||
url = spotdl.generate_youtube_url(raw_song)
|
||||
assert url == expect_url
|
||||
|
||||
|
||||
def test_youtube_title():
|
||||
expect_title = 'Intro - David André Østby'
|
||||
content = spotdl.go_pafy(raw_song)
|
||||
title = spotdl.get_youtube_title(content)
|
||||
assert title == expect_title
|
||||
|
||||
|
||||
def test_check_exists():
|
||||
expect_check = False
|
||||
content = spotdl.go_pafy(raw_song)
|
||||
@@ -28,12 +32,14 @@ def test_check_exists():
|
||||
check = spotdl.check_exists(music_file, raw_song)
|
||||
assert check == expect_check
|
||||
|
||||
|
||||
def test_download():
|
||||
expect_download = True
|
||||
content = spotdl.go_pafy(raw_song)
|
||||
download = spotdl.download_song(content)
|
||||
assert download == expect_download
|
||||
|
||||
|
||||
def test_convert():
|
||||
# exit code None = success
|
||||
expect_convert = None
|
||||
@@ -45,6 +51,7 @@ def test_convert():
|
||||
convert = spotdl.convert.song(input_song, output_song)
|
||||
assert convert == expect_convert
|
||||
|
||||
|
||||
def test_metadata():
|
||||
expect_metadata = True
|
||||
content = spotdl.go_pafy(raw_song)
|
||||
@@ -60,6 +67,7 @@ def test_metadata():
|
||||
|
||||
assert metadata_output == (metadata_input == expect_metadata)
|
||||
|
||||
|
||||
def check_exists2():
|
||||
expect_check = True
|
||||
content = spotdl.go_pafy(raw_song)
|
||||
|
||||
@@ -4,18 +4,21 @@ import spotdl
|
||||
|
||||
username = 'alex'
|
||||
|
||||
|
||||
def test_user():
|
||||
expect_playlists = 7
|
||||
playlists = spotdl.spotify.user_playlists(username)
|
||||
playlists = len(playlists['items'])
|
||||
assert playlists == expect_playlists
|
||||
|
||||
|
||||
def test_playlist():
|
||||
expect_tracks = 14
|
||||
playlist = spotdl.spotify.user_playlists(username)['items'][0]
|
||||
tracks = playlist['tracks']['total']
|
||||
assert tracks == expect_tracks
|
||||
|
||||
|
||||
def test_tracks():
|
||||
playlist = spotdl.spotify.user_playlists(username)['items'][0]
|
||||
expect_lines = playlist['tracks']['total']
|
||||
|
||||
Reference in New Issue
Block a user