Example #1
0
def test_restore(test_snapshot_filename):
    ledis = Ledis()
    ledis.set("hello", "world")
    ledis.sadd("set_type", 1, 2, 3)
    ledis.save(test_snapshot_filename)

    # Clear current state
    ledis.storage = {}
    assert ledis.get("hello") is None
    assert ledis.get("set_type") is None

    # Restore from persistent data
    ledis.restore(test_snapshot_filename)
    assert ledis.get("hello") == "world"
    assert ledis.smembers("set_type") == [1, 2, 3]
Example #2
0
def test_save(test_snapshot_filename):
    ledis = Ledis()
    ledis.set("hello", "world")
    ledis.save(test_snapshot_filename)

    assert file_exists(path.join(SNAPSHOT_DIR, f"{test_snapshot_filename}.db"))