class Test(unittest.TestCase): def setUp(self): self.album = Album() def test_sample_1(self): test_songs = [(30, "one"), (30, "two"), (15, "three"), (25, "four")] self.album.load([Song(song) for song in test_songs]) self.assertEqual(self.album.find_bests(2), ["four", "two"]) def test_load_songs_from_file(self): self.album.load_from_file("sample.txt")
def scrape_albums(artist, cursor): res = [] count = 0 artist_name = artist.get_song_page_name() for album in artist.get_album_infos(): album = Album(artist.artist_name, album) res.append(album) print(f'{album.title} [{len(album.songs)}]') for song_name in album.songs: count = count + 1 if _song_exists(song_name, artist_name, cursor): print(f' ↛ {song_name} [skip]') else: song = Song(artist_name, song_name) _insert_song(song, album, cursor) return res, count
def setUp(self): self.album = Album()