Пример #1
0
def test_base_player_capabilities():
    player = FakePlayer()

    assert repr(player) == "<Player FakePlayer>"

    player.part = TimeContainer(1, 1, 1)
    assert player.play("F4", "F5", velocity=63) == {
        "part": TimeContainer(1, 1, 1),
        "notes": [Note("F4"), Note("F5")],
        "duration": Whole,
        "velocity": 63
    }
Пример #2
0
def test_time_signature_generator_run(time_signature_args, note_duration, num_time, last_time_args):
    time_signature = TimeSignature(*time_signature_args)
    time_iterator = list(time_signature.gen(note_duration))

    assert len(time_iterator) == num_time

    assert time_iterator[-1] == TimeContainer(*last_time_args)
Пример #3
0
def test_time_signature_generator_infinite_loop():
    time_signature = TimeSignature(4, 4)
    gen = time_signature.gen(Whole, go_on=True)

    for _ in range(10):
        time_section = next(gen)

    assert time_section == TimeContainer(10, 1, 1)
Пример #4
0
def test_time_container_check():
    time_container = TimeContainer(3, 2, 1, 3, 7)

    assert time_container.check(bar=3)
    assert not time_container.check(bar=2)

    assert time_container.check(bar=(1, 3))
    assert not time_container.check(bar=(1, 2))

    assert time_container.check(bar=3, measure=2)
    assert not time_container.check(bar=3, measure=1)
Пример #5
0
def test_time_container_repr():
    assert repr(TimeContainer(3, 2, 1, 6, 7)) == "<Time 3 | 2 / 1 ( 6 : 7 )>"
Пример #6
0
def test_time_container_copy():
    time_container = TimeContainer(3, 2, 1, 3, 7)

    assert time_container == time_container.copy()
Пример #7
0
def test_time_container_comparison_method():
    assert TimeContainer(1, 2, 1) > TimeContainer(1, 1, 1)

    assert TimeContainer(1, 1, 1, 2, 7) > TimeContainer(1, 1, 1, 1, 7)

    assert TimeContainer(1, 1, 1, 1, 7) >= TimeContainer(1, 1, 1, 1, 7)

    assert TimeContainer(1, 1, 1, 5, 7) > TimeContainer(1, 1, 1, 2, 3)

    assert not TimeContainer(1, 1, 2) < TimeContainer(1, 1, 1)

    assert not TimeContainer(1, 2, 1) < TimeContainer(1, 1, 1)
Пример #8
0
def test_time_container_equal_method():
    assert TimeContainer(1, 1, 1) == TimeContainer(1, 1, 1, 1, 1)
Пример #9
0
def test_time_signature_generator_with_note_range():
    time_signature = TimeSignature(4, 8)
    time_iterator = list(time_signature.gen(Quarter, Whole))

    assert time_iterator[-1] == TimeContainer(2, 3, 1)