feat(core): domain models + Store (schema, connection, meta)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
from photoflow.core import Store
|
||||
|
||||
|
||||
def test_connect_creates_schema_and_version(tmp_path):
|
||||
db = str(tmp_path / "t.db")
|
||||
s = Store(db).connect()
|
||||
assert s.get_meta("schema_version") == "1"
|
||||
# tables exist
|
||||
names = {r["name"] for r in s.conn.execute(
|
||||
"SELECT name FROM sqlite_master WHERE type='table'")}
|
||||
assert {"assets", "tags", "asset_tags", "clusters",
|
||||
"cluster_members", "writeback_log", "meta"} <= names
|
||||
s.close()
|
||||
|
||||
|
||||
def test_meta_roundtrip_and_default(tmp_path):
|
||||
s = Store(str(tmp_path / "t.db")).connect()
|
||||
assert s.get_meta("missing") is None
|
||||
assert s.get_meta("missing", "x") == "x"
|
||||
s.set_meta("last_ingest_at", "2026-06-27T00:00:00Z")
|
||||
assert s.get_meta("last_ingest_at") == "2026-06-27T00:00:00Z"
|
||||
s.set_meta("last_ingest_at", "newer") # upsert
|
||||
assert s.get_meta("last_ingest_at") == "newer"
|
||||
s.close()
|
||||
Reference in New Issue
Block a user