예제 #1
0
def test_msgpacks_fail_to_load_invalid_data():
    def default(ob):
        return msgpack.ExtType(127, b"")

    with pytest.raises(ValueError):
        props.Msgpack().prepare_to_load(
            None, msgpack.packb(object(), default=default))
예제 #2
0
def test_msgpacks_fail_to_dump_invalid_data():
    with pytest.raises(TypeError):
        props.Msgpack().prepare_to_store(None, object())
예제 #3
0
def test_msgpacks_load_data_from_msgpack_on_load():
    data = {"foo": {"bar": 42}}
    assert props.Msgpack().prepare_to_load(None, msgpack.packb(data)) == data
예제 #4
0
def test_msgpacks_dump_and_load_entities(person, mutant, human):
    for entity in (person, mutant, human):
        msgpack = props.Msgpack()
        entity_msgpack = msgpack.prepare_to_store(None, entity)
        loaded_entity = msgpack.prepare_to_load(None, entity_msgpack)
        assert loaded_entity == entity
예제 #5
0
def test_msgpacks_dump_data_to_msgpack_on_store():
    data = {"foo": {"bar": 42}}
    assert props.Msgpack().prepare_to_store(None, data) == msgpack.packb(data)