def test_to_list():
    with open('pythonic_garage_band/twobands.json', 'r') as file:
        bands = json.loads(file.read())

    assert len(bands) == 2

    Band.create_from_data(bands[0])
    Band.create_from_data(bands[1])

    assert len(Band.to_list()) == 2
def test_create_bands_from_file():
    with open('pythonic_garage_band/bands.json', 'r') as file:
        bands = json.loads(file.read())

    assert len(bands) == 1

    band = Band.create_from_data(bands[0])

    assert band.name == "Volcano"
def test_band_members():
    band = Band.create_from_data(BandData)
    assert band.name == "Volcano"
    assert len(band.members) == len(BandData["Members"])

    for member in band.members:
        assert isinstance(member, Musician)

    assert isinstance(band.members[0], Guitarist)
    assert isinstance(band.members[1], Drummer)
    assert isinstance(band.members[2], Bassist)

    assert band.members[0].name == "Tom"
    assert band.members[1].name == "Robert"
    assert band.members[2].name == "Riley"
Exemplo n.º 4
0
def test_create_bands():
    Band.create_from_data('pythonic_garage_band\\assets\\bands.yaml')
    assert str(Band.to_list()[0]) == "The band Band1"
    assert str(Band.to_list()[1]) == "The band Band2"
    assert repr(Band.to_list()[0]) == "The band instance with name = Band1, members = [Bassist instance. Name: Simon, Guitarist instance. Name: Krishnan]"
    assert repr(Band.to_list()[1]) == "The band instance with name = Band2, members = [drummer instance. Name: Vara, Guitarist instance. Name: JB]"