mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-12-29 05:11:21 +00:00
Increase coverage (#218)
* Monkeypatch fetch user and use pytest.tempdir * Cover spotify_tools.grab_album() * Cover avconv conversion * Cover grab_single() * Reduce code repetition * Move grab_playlist() to spotify_tools.py * Move Spotify specific functions to spotify_tools.py * Refactoring * Return track list from write_tracks() * Fix tests * Cover more cases in generate_youtube_url() * Test for unavailable audio streams * Test for filename without spaces * handle.py 100% coverage * Improve config tests * Speed up tests * Install avconv and libfdk-aac * Some cleaning * FFmpeg with libfdk-aac, libopus * Some refactoring * Convert tmpdir to string * Cover YouTube title when downloading from list * Explicitly cover some internals.py functions
This commit is contained in:
34
test/test_handle.py
Normal file
34
test/test_handle.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from core import handle
|
||||
|
||||
import pytest
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def test_log_str_to_int():
|
||||
expect_levels = [20, 30, 40, 10]
|
||||
levels = [handle.log_leveller(level)
|
||||
for level in handle._LOG_LEVELS_STR]
|
||||
assert levels == expect_levels
|
||||
|
||||
|
||||
class TestConfig:
|
||||
def test_default_config(self, tmpdir):
|
||||
expect_config = handle.default_conf['spotify-downloader']
|
||||
global config_path
|
||||
config_path = os.path.join(str(tmpdir), 'config.yml')
|
||||
config = handle.get_config(config_path)
|
||||
assert config == expect_config
|
||||
|
||||
def test_modified_config(self):
|
||||
default_config = handle.default_conf['spotify-downloader']
|
||||
modified_config = dict(default_config)
|
||||
modified_config['file-format'] = 'just_a_test'
|
||||
config = handle.merge(default_config, modified_config)
|
||||
assert config['file-format'] == modified_config['file-format']
|
||||
|
||||
|
||||
def test_grouped_arguments(tmpdir):
|
||||
sys.path[0] = str(tmpdir)
|
||||
with pytest.raises(SystemExit):
|
||||
handle.get_arguments(to_group=True, to_merge=True)
|
||||
Reference in New Issue
Block a user