Exemplo n.º 1
0
def test_add_note_order():
    c = Chord(Note(name='C'), Note(name='E'), Note(name='G'))
    c.add_note(note=Note(name='Bb'))
    assert len(c.notes) == 4
    assert c.notes[0] == Note(name='C')
    assert c.notes[1] == Note(name='E')
    assert c.notes[2] == Note(name='G')
    assert c.notes[3] == Note(name='Bb')

    c = Chord(Note(name='C'), Note(name='E'), Note(name='G'))
    c.add_note(note=Note(name='C', octave=3))
    assert len(c.notes) == 4
    assert c.notes[0] == Note(name='C', octave=3)
    assert c.notes[1] == Note(name='C')
    assert c.notes[2] == Note(name='E')
    assert c.notes[3] == Note(name='G')

    c = Chord(Note(name='C'), Note(name='E'), Note(name='G'))
    c.add_note(note=Note(name='C', octave=3))
    c.add_note(note=Note(name='G', octave=3))
    assert len(c.notes) == 5
    assert c.notes[0] == Note(name='C', octave=3)
    assert c.notes[1] == Note(name='G', octave=3)
    assert c.notes[2] == Note(name='C')
    assert c.notes[3] == Note(name='E')
    assert c.notes[4] == Note(name='G')
Exemplo n.º 2
0
def test_str():
    c = Chord(Note(name='C'), Note(name='E'), Note(name='G'))
    assert 'C4,E4,G4' == str(c)

    c.add_note(note=Note(name='C', octave=5))
    assert 'C4,E4,G4,C5' == str(c)