summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2024-05-07 21:19:10 +0200
committerYuval Adam <_@yuv.al>2024-05-07 21:19:10 +0200
commit48f499507187e76f02acb563b46e6b32328b0777 (patch)
tree6ef24bae957a49d1367a0d2c4375b7dc6efc81b9 /tests
parente5ccbaf85a8865eaaec20ff5c1ef11ff7058d7a2 (diff)
Test for invalid paths
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stash.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/test_stash.py b/tests/test_stash.py
index 6b9e47f..88cc466 100644
--- a/tests/test_stash.py
+++ b/tests/test_stash.py
@@ -5,6 +5,8 @@ from ymlstash import YmlStash
from dataclasses import dataclass
from typing import ClassVar
+TEST_STASH_PATH = "/tmp"
+
@dataclass
class User:
@@ -13,14 +15,19 @@ class User:
def test_stash_path():
- stash = YmlStash(User, "foo")
- assert stash.path == Path("foo")
- stash = YmlStash(User, Path("foo"))
- assert stash.path == Path("foo")
+ stash = YmlStash(User, ".")
+ assert stash.path == Path(".")
+ stash = YmlStash(User, Path("."))
+ assert stash.path == Path(".")
+
+
+def test_invalid_path():
+ with pytest.raises(Exception):
+ YmlStash(User, "/tmp/does/not/exist")
def test_stash():
- stash = YmlStash(User, "/tmp/")
+ stash = YmlStash(User, TEST_STASH_PATH)
yuval = User(name="yuval", age=42)
stash.save(yuval, "foo")
assert stash.list_keys() == ["foo"]
@@ -43,7 +50,7 @@ def test_key_field():
name: str
key: ClassVar[str] = "name"
- stash = YmlStash(Dog, "/tmp/")
+ stash = YmlStash(Dog, TEST_STASH_PATH)
terra = Dog(name="terra")
stash.save(terra)
assert stash.list_keys() == ["terra"]