Ejemplo n.º 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
Ejemplo n.º 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)
            ]))
Ejemplo n.º 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'))
Ejemplo n.º 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"))))
Ejemplo n.º 5
0
def test_blob_roundtrips():
    assert_roundtrips(Message('/my/test', b"hello"))
Ejemplo n.º 6
0
def test_bool_roundtrips():
    assert_roundtrips(Message('/my/test', True, False))
Ejemplo n.º 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
Ejemplo n.º 8
0
def test_message_is_not_bundle():
    assert Message('#bundle') != Bundle(ASAP.now())
Ejemplo n.º 9
0
def test_midi_roundtrips():
    assert_roundtrips(Message('/my/test', MIDIMessage(1, 2, 3, 4)))
Ejemplo n.º 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'))
Ejemplo n.º 11
0
def test_asap():
    assert_roundtrips(Message('/my/test', ASAP.now()))
Ejemplo n.º 12
0
def test_setitem():
    msg = Message('/my/test', 'a', 'b', 'c')
    msg[2] = 100
    assert msg == Message('/my/test', 'a', 'b', 100)
Ejemplo n.º 13
0
def test_clear():
    msg = Message('/my/test', 'a', 'b', 'c')
    assert len(msg) == 3
    msg.clear()
    assert len(msg) == 0
Ejemplo n.º 14
0
def test_none_roundtrips():
    assert_roundtrips(Message('/my/test', None))
Ejemplo n.º 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))
Ejemplo n.º 16
0
def test_delitem():
    msg = Message('/my/test', 'a', 'b', 'c')
    del msg[1]
    assert msg == Message('/my/test', 'a', 'c')
Ejemplo n.º 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)
Ejemplo n.º 18
0
def test_datetime_roundtrips2():
    assert_roundtrips(Message('/my/test', datetime(2019, 10, 2)))
Ejemplo n.º 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)))
Ejemplo n.º 20
0
def test_datetime_roundtrips3():
    assert_roundtrips(Message('/my/test', datetime(2019, 10, 2, 21, 9, 8)))
Ejemplo n.º 21
0
def test_getitem():
    assert Message('/my/test', 'a', 'b', 'c')[2] == Element.from_pair('c')
Ejemplo n.º 22
0
def test_float32_roundtrips():
    assert_roundtrips(Message('/my/test', 10.0, 0.5, math.inf, -math.inf))
Ejemplo n.º 23
0
def test_values():
    assert list(Message('/my/test', 10, True,
                        "Buffalo").values()) == [10, True, "Buffalo"]
Ejemplo n.º 24
0
def test_rgba_roundtrips():
    assert_roundtrips(Message('/my/test', RGBA(255, 128, 0, 100)))
Ejemplo n.º 25
0
def test_str_roundtrips():
    assert_roundtrips(Message('/my/test', "hello"))
Ejemplo n.º 26
0
def test_insert():
    a = Message('/my/test', 10, 20)
    b = Message('/my/test', 20)
    b.insert(0, 10)
    assert a == b
Ejemplo n.º 27
0
def test_empty_message_roundtrips():
    assert_roundtrips(Message('/my/test'))