Пример #1
0
def test_delete_deletes_file_when_last_key() -> None:
    path = Path.cwd() / "config.json"

    storage = Storage(str(path))
    storage.set("key", "value")
    storage.delete("key")

    assert not path.exists()
Пример #2
0
def test_delete_unsets_value() -> None:
    path = Path.cwd() / "config.json"

    storage = Storage(str(path))
    storage.set("key1", "value1")
    storage.set("key2", "value2")
    storage.set("key3", "value3")
    storage.delete("key2")

    data = json.loads(path.read_text(encoding="utf-8"))
    assert data == {"key1": "value1", "key3": "value3"}