From c81a26e65aafab049b944a86863e7d851072bd8b Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Tue, 7 May 2024 16:15:48 +0200 Subject: Implement basic stash operations --- tests/test_stash.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_stash.py b/tests/test_stash.py index b87c882..defdd7e 100644 --- a/tests/test_stash.py +++ b/tests/test_stash.py @@ -1,9 +1,27 @@ from pathlib import Path from ymlstash import YmlStash +from dataclasses import dataclass + + +@dataclass +class User: + name: str + age: int def test_stash_path(): - stash = YmlStash("foo") + stash = YmlStash(User, "foo") assert stash.path == Path("foo") - stash = YmlStash(Path("foo")) + stash = YmlStash(User, Path("foo")) assert stash.path == Path("foo") + + +def test_stash(): + stash = YmlStash(User, "/tmp/") + yuval = User(name="yuval", age=42) + stash.save("foo", yuval) + assert stash.list_all_keys() == ["foo"] + obj = stash.load("foo") + assert obj == yuval + stash.drop() + assert stash.list_all_keys() == [] -- cgit v1.3.1