def test_raw_file():
    before = RawFileProvider(relative_path, root)
    broker = dr.Broker()
    broker[thing] = before

    tmp_path = mkdtemp()
    try:
        hydra = Hydration(tmp_path)
        hydra.dehydrate(thing, broker)
        after = hydra.hydrate()[thing]
        assert after.content == before.content
    finally:
        if tmp_path and os.path.exists(tmp_path):
            fs.remove(tmp_path)
示例#2
0
def test_round_trip():
    tmp_path = mkdtemp()
    try:
        h = Hydration(tmp_path)

        broker = dr.Broker()
        broker[thing] = Foo()
        broker.exec_times[thing] = 0.5
        h.dehydrate(thing, broker)
        fn = ".".join([dr.get_name(thing), h.ser_name])
        assert os.path.exists(os.path.join(h.meta_data, fn))

        broker = h.hydrate()
        assert thing in broker
        assert broker.exec_times[thing] >= 0.5
        foo = broker[thing]
        assert foo.a == 1
        assert foo.b == 2
    finally:
        pass
        if os.path.exists(tmp_path):
            fs.remove(tmp_path)