def test_KeyDBFactory_diff(tmp_Path): with KeyDBWrapper(tmp_Path) as db: window = KeyDBWindow("window", db) factory = KeyDBFactory(window, str, lambda data, name: safetype(data)) assert factory.list() == [] factory.write("five", 5) assert factory.list() == ["five"] value = factory.read("five") assert value == safetype(5) factory.delete("five") assert factory.list() == []
def test_KeyDBFactory_diff(): with KeyDBWrapper("./db") as db: window = KeyDBWindow("window", db) factory = KeyDBFactory(window, str, str) assert factory.list() == [] factory.write("five", 5) assert factory.list() == ["five"] value = factory.read("five") assert value == str(5) factory.delete("five") assert factory.list() == []
def test_KeyDBFactory_copy(tmp_Path): with KeyDBWrapper(Path("db1", tmp_Path)) as db1: window1 = KeyDBWindow("window", db1) factory1 = KeyDBFactory(window1, str, lambda data, name: safetype(data)) assert factory1.list() == [] factory1.write("five", 5) with KeyDBWrapper(Path("db2", tmp_Path)) as db2: window2 = KeyDBWindow("other", db2) factory2 = KeyDBFactory(window2, str, lambda data, name: safetype(data)) factory2.copy("five", window1) value = factory2.read("five") assert value == safetype(5)