예제 #1
0
파일: test_chord.py 프로젝트: iskyd/babs
def test_create_from_root_with_alt():
    c = Chord.create_from_root(root=Note(name='C', alt=Note.SHARP),
                               chord_type=Chord.MINOR_TYPE)

    assert 'D#4' in str(c).split(',')

    c = Chord.create_from_root(root=Note(name='C', alt=Note.FLAT),
                               chord_type=Chord.MINOR_TYPE,
                               alt=Note.FLAT)

    assert 'Eb4' in str(c).split(',')
예제 #2
0
파일: test_chord.py 프로젝트: iskyd/babs
def test_create_from_root_with_int_octave():
    c = Chord.create_from_root(root=Note(name='G', octave=3), octave=4)

    assert Note(name='G', octave=3) in c.notes
    assert Note(name='B', octave=4) in c.notes
    assert Note(name='D', octave=4) in c.notes

    c = Chord.create_from_root(root=Note(name='F', octave=4), octave=3)

    assert Note(name='F', octave=4) in c.notes
    assert Note(name='A', octave=3) in c.notes
    assert Note(name='C', octave=3) in c.notes
예제 #3
0
파일: test_chord.py 프로젝트: iskyd/babs
def test_remove_note():
    c = Chord.create_from_root(root=Note(name='C'))
    c.remove_note(note=Note(name='E'))
    assert len(c.notes) == 2
    assert c.notes[0] == Note(name='C')
    assert c.notes[1] == Note(name='G')

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.MINOR_TYPE)
    c.remove_note(note=Note(name='Eb'))
    assert len(c.notes) == 2
    assert c.notes[0] == Note(name='C')
    assert c.notes[1] == Note(name='G')
예제 #4
0
파일: test_chord.py 프로젝트: iskyd/babs
def test_create_from_root_with_callable_octave():
    c = Chord.create_from_root(root=Note(name='G', octave=3),
                               octave=lambda root_octave, i, distance: i + 1)

    assert Note(name='G', octave=3) in c.notes
    assert Note(name='B', octave=1) in c.notes
    assert Note(name='D', octave=2) in c.notes

    c = Chord.create_from_root(
        root=Note(name='F', octave=4),
        octave=lambda root_octave, i, distance: root_octave + i + 1)

    assert Note(name='F', octave=4) in c.notes
    assert Note(name='A', octave=5) in c.notes
    assert Note(name='C', octave=6) in c.notes

    with pytest.raises(TypeError):
        Chord.create_from_root(root=Note(name='F', octave=4),
                               octave=lambda: 'invalid')
예제 #5
0
파일: test_chord.py 프로젝트: iskyd/babs
def test_create_from_root():
    c = Chord.create_from_root(root=Note(name='C'))

    assert len(c.notes) == 3
    assert Note(name='C') in c.notes
    assert Note(name='E') in c.notes
    assert Note(name='G') in c.notes

    c = Chord.create_from_root(root=Note(name='G'))

    assert len(c.notes) == 3
    assert Note(name='G') in c.notes
    assert Note(name='B') in c.notes
    assert Note(name='D') in c.notes

    c = Chord.create_from_root(root=Note(name='G', octave=3))

    assert Note(name='G', octave=3) in c.notes
    assert Note(name='B', octave=3) in c.notes
    assert Note(name='D', octave=3) in c.notes

    assert Chord.create_from_root(root=Note(name='C')).strict is True
    assert Chord.create_from_root(root=Note(name='C'),
                                  strict=True).strict is True
    assert Chord.create_from_root(root=Note(name='C'),
                                  strict=False).strict is False
예제 #6
0
파일: test_chord.py 프로젝트: iskyd/babs
def test_create_from_root_with_invalid_octave():
    c = Chord.create_from_root(root=Note(name='C'), octave='invalid')

    assert Note(name='C', octave=4) in c.notes
    assert Note(name='E', octave=4) in c.notes
    assert Note(name='G', octave=4) in c.notes
예제 #7
0
파일: test_chord.py 프로젝트: iskyd/babs
def test_create_from_root_with_chord_type():
    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.MAJOR_TYPE)
    assert c == Chord(Note(name='C'), Note(name='E'), Note(name='G'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.MAJOR_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='E'), Note(name='G'),
                      Note(name='B'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.MINOR_TYPE)
    assert c == Chord(Note(name='C'), Note(name='Eb'), Note(name='G'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.MINOR_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='Eb'), Note(name='G'),
                      Note(name='Bb'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.DOMINANT_TYPE)
    assert c == Chord(Note(name='C'), Note(name='E'), Note(name='G'),
                      Note(name='Bb'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.MINOR_MAJOR_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='Eb'), Note(name='G'),
                      Note(name='B'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.HALF_DIMINISHED_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='Eb'), Note(name='Gb'),
                      Note(name='Bb'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.DIMINISHED_TYPE)
    assert c == Chord(Note(name='C'), Note(name='Eb'), Note(name='Gb'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.DIMINISHED_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='Eb'), Note(name='Gb'),
                      Note(name='A'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.AUGMENTED_TYPE)
    assert c == Chord(Note(name='C'), Note(name='E'), Note(name='G#'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.AUGMENTED_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='E'), Note(name='G#'),
                      Note(name='Bb'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.AUGMENTED_MAJOR_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='E'), Note(name='G#'),
                      Note(name='B'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.MAJOR_SIXTH_TYPE)
    assert c == Chord(Note(name='C'), Note(name='E'), Note(name='G'),
                      Note(name='A'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.MINOR_SIXTH_TYPE)
    assert c == Chord(Note(name='C'), Note(name='Eb'), Note(name='G'),
                      Note(name='A'))

    c = Chord.create_from_root(root=Note(name='C'), chord_type=Chord.SUS4_TYPE)
    assert c == Chord(Note(name='C'), Note(name='F'), Note(name='G'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.SUS4_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='F'), Note(name='G'),
                      Note(name='Bb'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.SUS4_MAJOR_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='F'), Note(name='G'),
                      Note(name='B'))

    c = Chord.create_from_root(root=Note(name='C'), chord_type=Chord.SUS2_TYPE)
    assert c == Chord(Note(name='C'), Note(name='D'), Note(name='G'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.SUS2_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='D'), Note(name='G'),
                      Note(name='Bb'))

    c = Chord.create_from_root(root=Note(name='C'),
                               chord_type=Chord.SUS2_MAJOR_SEVEN_TYPE)
    assert c == Chord(Note(name='C'), Note(name='D'), Note(name='G'),
                      Note(name='B'))