Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_check_track_exists_before_download(tmpdir):
expect_check = False
const.args.folder = str(tmpdir)
# prerequisites for determining filename
songname = internals.format_string(const.args.file_format, meta_tags)
global file_name
file_name = internals.sanitize_title(songname)
track_existence = downloader.CheckExists(file_name, meta_tags)
check = track_existence.already_exists(TRACK_URL)
assert check == expect_check
def filename_fixture(metadata_fixture):
songname = internals.format_string(const.args.file_format, metadata_fixture)
filename = internals.sanitize_title(songname)
return filename
def test_without_spaces(self, metadata_fixture):
const.args.no_spaces = True
title = internals.format_string(const.args.file_format, metadata_fixture)
assert title == EXPECTED_SPOTIFY_TITLE.replace(" ", "_")
def test_with_spaces(self):
title = internals.format_string(const.args.file_format, meta_tags)
assert title == EXPECTED_TITLE
def refine_songname(self, songname):
if self.meta_tags is not None:
refined_songname = internals.format_string(
const.args.file_format,
self.meta_tags,
slugification=True,
total_songs=self.total_songs,
)
log.debug(
'Refining songname from "{0}" to "{1}"'.format(
songname, refined_songname
)
)
if not refined_songname == " - ":
songname = refined_songname
else:
songname = internals.sanitize_title(songname)
return songname
def __init__(self, raw_song, meta_tags):
self.raw_song = raw_song
self.meta_tags = meta_tags
if meta_tags is None:
self.search_query = raw_song
else:
self.search_query = internals.format_string(
const.args.search_format, meta_tags, force_spaces=True
)