def test_details(self): album = Album("The Sound of Perseverance") song = Song("Scavenger of Human Sorrow", 6.56, False) album.add_song(song) message = album.details().strip() expected = "Album The Sound of Perseverance\n== Scavenger of Human Sorrow - 6.56"
def remove_album(self, album_name): try: album = next(filter(lambda a: a.name == album_name, self.albums)) if album.published: return f"Album has been published. It cannot be removed." self.albums.remove(album) return f"Album {album_name} has been removed." except StopIteration: return f"Album {album_name} is not found." def details(self): data = f"Band {self.name}\n" for a in self.albums: data += a.details() return data song = Song("Running in the 90s", 3.45, False) print(song.get_info()) album = Album("Initial D", song) second_song = Song("Around the World", 2.34, False) print(album.add_song(second_song)) print(album.details()) print(album.publish()) band = Band("Manuel") print(band.add_album(album)) print(band.remove_album("Initial D")) print(band.details())
def test_album_init(self): album = Album("The Sound of Perseverance") message = album.details().strip() expected = "Album The Sound of Perseverance" self.assertEqual(message, expected)