Custom YouTube search string (#261)

* Custom YouTube search string

* Fix sorting issues on < Python 3.6
This commit is contained in:
Ritiek Malhotra
2018-04-08 15:56:44 +05:30
committed by GitHub
parent 4d18224bb7
commit fc226442fe
7 changed files with 60 additions and 34 deletions

View File

@@ -1,8 +1,12 @@
import yaml
from core import handle
from core import const
import pytest
import os
import sys
import argparse
def test_log_str_to_int():
@@ -21,11 +25,23 @@ class TestConfig:
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']
global modified_config
modified_config = dict(handle.default_conf)
modified_config['spotify-downloader']['file-format'] = 'just_a_test'
merged_config = handle.merge(handle.default_conf, modified_config)
assert merged_config == modified_config
def test_custom_config_path(self, tmpdir):
parser = argparse.ArgumentParser()
with open(config_path, 'w') as config_file:
yaml.dump(modified_config, config_file, default_flow_style=False)
overridden_config = handle.override_config(config_path,
parser,
raw_args='')
modified_values = [ str(value) for value in modified_config['spotify-downloader'].values() ]
overridden_config.folder = os.path.realpath(overridden_config.folder)
overridden_values = [ str(value) for value in overridden_config.__dict__.values() ]
assert sorted(overridden_values) == sorted(modified_values)
def test_grouped_arguments(tmpdir):

View File

@@ -25,13 +25,13 @@ def test_metadata():
class TestFileFormat:
def test_with_spaces(self):
expect_title = 'David André Østby - Intro'
title = internals.generate_songname(const.args.file_format, meta_tags)
title = internals.format_string(const.args.file_format, meta_tags)
assert title == expect_title
def test_without_spaces(self):
expect_title = 'David_André_Østby_-_Intro'
const.args.no_spaces = True
title = internals.generate_songname(const.args.file_format, meta_tags)
title = internals.format_string(const.args.file_format, meta_tags)
assert title == expect_title
@@ -53,7 +53,7 @@ def test_check_track_exists_before_download(tmpdir):
expect_check = False
const.args.folder = str(tmpdir)
# prerequisites for determining filename
songname = internals.generate_songname(const.args.file_format, meta_tags)
songname = internals.format_string(const.args.file_format, meta_tags)
global file_name
file_name = internals.sanitize_title(songname)
check = spotdl.check_exists(file_name, raw_song, meta_tags)