def test_find_songs(song_metadata_as_json_obj, test_album): songs = _find_songs(song_metadata_as_json_obj, test_album) assert len(songs) == 2 song = find_song(songs, disc=2, track=3) assert_dummy_test_song(song)
def to_action_options(file: Path, options) -> Mapping[str, Union[Optional[Song], bool, Optional[int], Optional[Path]]]: disc_and_track = extract_disc_and_track_number(file) disc: Optional[int] = None track: Optional[int] = None if disc_and_track is not None: disc, track = disc_and_track return { 'song': find_song(options['songs'], disc=disc, track=track), 'disc': disc, 'track': track, 'is_original': is_itunes_bought_file(file), 'should_backup': options['should_backup'], 'cover_path': options['cover_path'], }
def test_extract_songs(test_metadata): songs = extract_songs(test_metadata) assert len(songs) == 14 song = find_song(songs, disc=1, track=3) assert song.album_artist == 'Kanye West' assert song.copyright == '℗ 2010 Roc-A-Fella Records, LLC' assert song.collection_id == 1440742903 assert song.album_name == 'My Beautiful Dark Twisted Fantasy' assert song.media_kind == 'song' assert song.disc_number == 1 assert song.track_number == 3 assert song.title == 'Power'
def test_find_song_not_matching(): assert find_song([], disc=3, track=4) is None assert find_song( [MockSong(disc_number=3, track_number=4)], disc=3, track=2) is None assert find_song( [MockSong(disc_number=3, track_number=4)], disc=1, track=4) is None
def test_find_song(): first_song = MockSong(disc_number=1, track_number=2) second_song = MockSong(disc_number=3, track_number=4) songs = [first_song, second_song] assert find_song(songs, disc=3, track=4) == second_song