Historique regroupé en un seul commit pour ne pas publier de données de production. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from ldap2nextcloud.state import StateDB, StateRow
|
|
|
|
ROW = StateRow(href="a.vcf", key="alice", fingerprint="f1", etag="e1")
|
|
|
|
|
|
def test_upsert_then_all(tmp_path):
|
|
with StateDB(tmp_path / "s.sqlite") as db:
|
|
db.upsert(ROW)
|
|
assert db.all() == {"a.vcf": ROW}
|
|
|
|
|
|
def test_upsert_overwrites(tmp_path):
|
|
with StateDB(tmp_path / "s.sqlite") as db:
|
|
db.upsert(ROW)
|
|
db.upsert(StateRow("a.vcf", "alice", "f2", None))
|
|
assert db.all()["a.vcf"] == StateRow("a.vcf", "alice", "f2", None)
|
|
|
|
|
|
def test_set_etag(tmp_path):
|
|
with StateDB(tmp_path / "s.sqlite") as db:
|
|
db.upsert(StateRow("a.vcf", "alice", "f1", None))
|
|
db.set_etag("a.vcf", "e9")
|
|
assert db.all()["a.vcf"].etag == "e9"
|
|
|
|
|
|
def test_delete(tmp_path):
|
|
with StateDB(tmp_path / "s.sqlite") as db:
|
|
db.upsert(ROW)
|
|
db.delete("a.vcf")
|
|
assert db.all() == {}
|
|
|
|
|
|
def test_persists_across_reopen(tmp_path):
|
|
with StateDB(tmp_path / "s.sqlite") as db:
|
|
db.upsert(ROW)
|
|
with StateDB(tmp_path / "s.sqlite") as db:
|
|
assert db.all() == {"a.vcf": ROW}
|
|
|
|
|
|
def test_creates_parent_directory(tmp_path):
|
|
with StateDB(tmp_path / "state" / "deep" / "s.sqlite") as db:
|
|
db.upsert(ROW)
|
|
assert (tmp_path / "state" / "deep" / "s.sqlite").is_file()
|