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'))
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"))))
def test_asap_eq(): assert ASAP.now() == ASAP(1991, 11, 14)
def test_asap_repr(): assert repr(ASAP.now()) == 'ASAP.now()'
def test_message_is_not_bundle(): assert Message('#bundle') != Bundle(ASAP.now())
def test_weird_stuff_in_bundle(): with pytest.raises(AssertionError): Bundle(ASAP.now(), 'oh no')
def test_asap(): assert_roundtrips(Message('/my/test', ASAP.now()))
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))
def test_getitem_bundle(): assert Bundle(ASAP.now(), Message('/my/test'), Message('/my/test', 1), Message('/my/test', 2))[2] == Message('/my/test', 2)
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