diff options
| author | Yuval Adam <_@yuv.al> | 2024-05-07 16:15:48 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2024-05-07 16:16:02 +0200 |
| commit | c81a26e65aafab049b944a86863e7d851072bd8b (patch) | |
| tree | 6f8824dadb7bf562be59a650bd37e3fb80750f1a /tests | |
| parent | c0056b2d9f5175d06b39834b013d16fa5d63a485 (diff) | |
Implement basic stash operations
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_stash.py | 22 |
1 files changed, 20 insertions, 2 deletions
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() == [] |
