def one_band(): some_band = Band( "Nirvana", [ Guitarist("Kurt Cobain"), Bassist("Krist Novoselic"), Drummer("Dave Grohl"), ], ) return some_band
def test_from_file(): with open("assets/bands.json") as f: bands = json.loads(f.read()) assert len(bands) == 1 nirvana_data = bands[0] nirvana = Band(nirvana_data["name"], nirvana_data["members"]) assert nirvana.name == "Nirvana"
def test_band_name(): nirvana = Band("Nirvana", []) assert nirvana.name == "Nirvana"
def test_band_repr(): nirvana = Band("Nirvana", []) actual = repr(nirvana) expected = "Band instance. name=Nirvana, members=[]" assert actual == expected
def test_to_list(): assert Band.to_list() == [] Band("The Nobodies", []) assert len(Band.to_list()) == 1
def test_band_str(): nirvana = Band("Nirvana", []) actual = str(nirvana) expected = "The band Nirvana" assert actual == expected
def test_to_list(): assert Band.to_list() == [] the_nobodies = Band("The Nobodies", []) all_bands = Band.to_list() assert len(all_bands) == 1 assert all_bands[0] == the_nobodies
def test_class_tracks_instances(): assert Band.to_list() == [] the_nobodies = Band("The Nobodies", []) assert len(Band.instances) == 1 assert Band.instances[0] == the_nobodies
def test_BandName(): actual = Band("radiohead").name expected = "radiohead" assert expected == actual