feat: Project Scaffold and Docker Packaging
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from tenbackward.state import load_posted, posted_path, save_posted
|
||||
|
||||
|
||||
def test_load_posted_creates_empty_when_missing(tmp_path: Path) -> None:
|
||||
state = load_posted(tmp_path)
|
||||
assert state == {}
|
||||
|
||||
|
||||
def test_round_trip_persists(tmp_path: Path) -> None:
|
||||
state = {"post-1": {"posted_at": "2024-01-01T00:00:00Z"}}
|
||||
save_posted(tmp_path, state)
|
||||
|
||||
assert posted_path(tmp_path).exists()
|
||||
again = load_posted(tmp_path)
|
||||
assert again == state
|
||||
|
||||
|
||||
def test_load_posted_handles_corrupt_file(tmp_path: Path) -> None:
|
||||
posted_path(tmp_path).parent.mkdir(parents=True, exist_ok=True)
|
||||
posted_path(tmp_path).write_text("not-json")
|
||||
assert load_posted(tmp_path) == {}
|
||||
|
||||
|
||||
def test_save_posted_creates_parent_dirs(tmp_path: Path) -> None:
|
||||
nested = tmp_path / "deep" / "data"
|
||||
save_posted(nested, {"x": 1})
|
||||
assert posted_path(nested).exists()
|
||||
Reference in New Issue
Block a user