<commit_before># -*- coding: UTF-8 -*-

import spotdl

raw_song = 'http://open.spotify.com/track/2e0jnySVkYF1pvBlpoNX1Y'

def test_spotify_title():
    expect_title = '<NAME> - Tilbake (SAEVIK Remix)'
    title = spotdl.generate_songname(raw_song)
    assert title == expect_title

def test_youtube_url():
    expect_url = 'youtube.com/watch?v=zkD4smbefbc'
    url = spotdl.generate_youtube_url(raw_song)
    assert url == expect_url

def test_youtube_title():
    expect_title = 'Tilbake (SAEVIK Remix) [Feat. Marie Hognestad] - <NAME>'
    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)
    music_file = spotdl.misc.generate_filename(content.title)
    music_file = spotdl.misc.fix_decoding(music_file)
    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
    content = spotdl.go_pafy(raw_song)
    music_file = spotdl.misc.generate_filename(content.title)
    music_file = spotdl.misc.fix_decoding(music_file)
    input_song = music_file + spotdl.args.input_ext
    output_song = music_file + spotdl.args.output_ext
    convert = spotdl.convert.song(input_song, output_song)
    assert convert == expect_convert

def test_metadata():
    expect_metadata = True
    content = spotdl.go_pafy(raw_song)
    music_file = spotdl.misc.generate_filename(content.title)
    music_file = spotdl.misc.fix_decoding(music_file)
    meta_tags = spotdl.generate_metadata(raw_song)
    output_song = music_file + spotdl.args.output_ext
    spotdl.metadata.embed(output_song, meta_tags)
    metadata = spotdl.check_exists(music_file, raw_song)
    assert metadata == expect_metadata<commit_msg>Switch to shorter song to lower test duration<commit_after># -*- coding: UTF-8 -*-

import spotdl

raw_song = 'http://open.spotify.com/track/0JlS7BXXD07hRmevDnbPDU'

def test_spotify_title():
    expect_title = '<NAME> - 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 - <NAME>'
    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)
    music_file = spotdl.misc.generate_filename(content.title)
    music_file = spotdl.misc.fix_decoding(music_file)
    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
    content = spotdl.go_pafy(raw_song)
    music_file = spotdl.misc.generate_filename(content.title)
    music_file = spotdl.misc.fix_decoding(music_file)
    input_song = music_file + spotdl.args.input_ext
    output_song = music_file + spotdl.args.output_ext
    convert = spotdl.convert.song(input_song, output_song)
    assert convert == expect_convert

def test_metadata():
    expect_metadata = True
    content = spotdl.go_pafy(raw_song)
    music_file = spotdl.misc.generate_filename(content.title)
    music_file = spotdl.misc.fix_decoding(music_file)
    meta_tags = spotdl.generate_metadata(raw_song)

    output_song = music_file + spotdl.args.output_ext
    metadata_output = spotdl.metadata.embed(output_song, meta_tags)

    input_song = music_file + spotdl.args.input_ext
    metadata_input = spotdl.metadata.embed(input_song, meta_tags)

    assert metadata_output == (metadata_input == expect_metadata)

def check_exists2():
    expect_check = True
    content = spotdl.go_pafy(raw_song)
    music_file = spotdl.misc.generate_filename(content.title)
    music_file = spotdl.misc.fix_decoding(music_file)
    check = spotdl.check_exists(music_file, raw_song)
    assert check == expect_check
{'fraction_non_alphanumeric': 0.09490373725934315, 'fraction_numerical': 0.0031710079275198188, 'mean_word_length': 4.301320528211284, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1833673', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1492, 'n_words': 262}