コード例 #1
0
ファイル: test_properties.py プロジェクト: aisola/anom-py
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
ファイル: test_properties.py プロジェクト: aisola/anom-py
def test_msgpacks_fail_to_dump_invalid_data():
    with pytest.raises(TypeError):
        props.Msgpack().prepare_to_store(None, object())
コード例 #3
0
ファイル: test_properties.py プロジェクト: aisola/anom-py
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
ファイル: test_properties.py プロジェクト: aisola/anom-py
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
ファイル: test_properties.py プロジェクト: aisola/anom-py
def test_msgpacks_dump_data_to_msgpack_on_store():
    data = {"foo": {"bar": 42}}
    assert props.Msgpack().prepare_to_store(None, data) == msgpack.packb(data)