Exemple #1
0
def test_adding_tuples():
    a = Message('/my/test', 1)

    b = Message('/my/test')
    b.append(1, tag='i')

    c = Message('/my/test')
    c.append((1, 'i'))

    assert a == b == c
Exemple #2
0
def test_float_roundtrips():
    assert_roundtrips(
        Message(
            '/my/test', *[
                Element(x, tag='d')
                for x in (10.0, 0.5, 12345.6789, math.pi, math.inf, -math.inf)
            ]))
Exemple #3
0
def test_setitem_bundle():
    msg = Bundle(ASAP.now(), Message('/my/test'), Message('/my/test', 1),
                 Message('/my/test', 2))
    msg[2] = Message('/oh/no', b'surprise')
    assert msg == Bundle(ASAP.now(),
                         Message('/my/test'), Message('/my/test', 1),
                         Message('/oh/no', b'surprise'))
Exemple #4
0
def test_bundle():
    assert_roundtrips(
        Bundle(ASAP.now(), Message('/my/test', 333, True),
               Message('/more/tests', "ok")))
    assert_roundtrips(
        Bundle(datetime(2019, 5, 2), Message('/my/test', 333, True),
               Message('/more/tests', "ok")))
    assert_roundtrips(
        Bundle(datetime.now(), Message('/my/test', 333, True),
               Message('/more/tests', "ok")))
    assert_roundtrips(
        Bundle(datetime.now(), Message('/my/test', 333, True),
               Bundle(datetime.now(), Message('/more/tests', "ok"))))
Exemple #5
0
def test_blob_roundtrips():
    assert_roundtrips(Message('/my/test', b"hello"))
Exemple #6
0
def test_bool_roundtrips():
    assert_roundtrips(Message('/my/test', True, False))
Exemple #7
0
def test_insert_bundle():
    a = Bundle(ASAP.now(), Message('/my/test'), Message('/hello'))
    b = Bundle(ASAP.now(), Message('/hello'))
    b.insert(0, Message('/my/test'))
    assert a == b
Exemple #8
0
def test_message_is_not_bundle():
    assert Message('#bundle') != Bundle(ASAP.now())
Exemple #9
0
def test_midi_roundtrips():
    assert_roundtrips(Message('/my/test', MIDIMessage(1, 2, 3, 4)))
Exemple #10
0
def test_character_roundtrips():
    assert_roundtrips(Message('/my/test', Element(ord('O'), 'c')))
    assert parse(bytes(Message('/my/test', Element('O', 'c')))) == Message(
        '/my/test', Element(ord('O'), 'c'))
Exemple #11
0
def test_asap():
    assert_roundtrips(Message('/my/test', ASAP.now()))
Exemple #12
0
def test_setitem():
    msg = Message('/my/test', 'a', 'b', 'c')
    msg[2] = 100
    assert msg == Message('/my/test', 'a', 'b', 100)
Exemple #13
0
def test_clear():
    msg = Message('/my/test', 'a', 'b', 'c')
    assert len(msg) == 3
    msg.clear()
    assert len(msg) == 0
Exemple #14
0
def test_none_roundtrips():
    assert_roundtrips(Message('/my/test', None))
Exemple #15
0
def test_delitem_bundle():
    msg = Bundle(ASAP.now(), Message('/my/test'), Message('/my/test', 1),
                 Message('/my/test', 2))
    del msg[1]
    assert msg == Bundle(ASAP.now(), Message('/my/test'),
                         Message('/my/test', 2))
Exemple #16
0
def test_delitem():
    msg = Message('/my/test', 'a', 'b', 'c')
    del msg[1]
    assert msg == Message('/my/test', 'a', 'c')
Exemple #17
0
def test_getitem_bundle():
    assert Bundle(ASAP.now(), Message('/my/test'), Message('/my/test', 1),
                  Message('/my/test', 2))[2] == Message('/my/test', 2)
Exemple #18
0
def test_datetime_roundtrips2():
    assert_roundtrips(Message('/my/test', datetime(2019, 10, 2)))
Exemple #19
0
def test_bundle2():
    timetag = datetime(2019, 9, 17, 21, 49, 43, 677925)
    assert_roundtrips(
        Bundle(timetag, Message('/some/test', 1),
               Message('/some/test', 2, timetag)))
Exemple #20
0
def test_datetime_roundtrips3():
    assert_roundtrips(Message('/my/test', datetime(2019, 10, 2, 21, 9, 8)))
Exemple #21
0
def test_getitem():
    assert Message('/my/test', 'a', 'b', 'c')[2] == Element.from_pair('c')
Exemple #22
0
def test_float32_roundtrips():
    assert_roundtrips(Message('/my/test', 10.0, 0.5, math.inf, -math.inf))
Exemple #23
0
def test_values():
    assert list(Message('/my/test', 10, True,
                        "Buffalo").values()) == [10, True, "Buffalo"]
Exemple #24
0
def test_rgba_roundtrips():
    assert_roundtrips(Message('/my/test', RGBA(255, 128, 0, 100)))
Exemple #25
0
def test_str_roundtrips():
    assert_roundtrips(Message('/my/test', "hello"))
Exemple #26
0
def test_insert():
    a = Message('/my/test', 10, 20)
    b = Message('/my/test', 20)
    b.insert(0, 10)
    assert a == b
Exemple #27
0
def test_empty_message_roundtrips():
    assert_roundtrips(Message('/my/test'))