feat(docs): save chat answers as docs — edit screen, commit + push to the .env docs branch
This commit is contained in:
@@ -44,3 +44,36 @@ def test_documents_unique_source_path() -> None:
|
||||
and {col.name for col in c.columns} == {"source", "path"}
|
||||
]
|
||||
assert uq, "documents must be unique on (source, path) — the upsert key"
|
||||
|
||||
|
||||
def test_doc_drafts_token_is_unique_not_null() -> None:
|
||||
"""Phase 59: the draft's URL credential — an unguessable uuid4,
|
||||
UNIQUE + NOT NULL (no "un-drafted" state, unlike the NULLable
|
||||
``saved_chats.share_token``)."""
|
||||
drafts = Base.metadata.tables["doc_drafts"]
|
||||
token = drafts.c["token"]
|
||||
assert token.nullable is False, "doc_drafts.token must be NOT NULL"
|
||||
uq = [
|
||||
c
|
||||
for c in drafts.constraints
|
||||
if isinstance(c, UniqueConstraint)
|
||||
and {col.name for col in c.columns} == {"token"}
|
||||
]
|
||||
assert uq, "doc_drafts must be unique on (token) — the URL credential"
|
||||
|
||||
|
||||
def test_doc_drafts_column_contract() -> None:
|
||||
"""Phase 59: the editable triple (title/path/body) + status +
|
||||
timestamps are NOT NULL; ``branch`` / ``commit_sha`` are NULL
|
||||
until the push endpoint records them."""
|
||||
drafts = Base.metadata.tables["doc_drafts"]
|
||||
assert set(drafts.c.keys()) == {
|
||||
"id", "token", "title", "path", "body", "status",
|
||||
"branch", "commit_sha", "created_at", "updated_at",
|
||||
}
|
||||
for name in ("title", "path", "body", "status", "created_at", "updated_at"):
|
||||
assert drafts.c[name].nullable is False, f"{name} must be NOT NULL"
|
||||
for name in ("branch", "commit_sha"):
|
||||
assert drafts.c[name].nullable is True, f"{name} must be NULL until pushed"
|
||||
assert drafts.c["status"].default is not None, "status needs an ORM default (draft)"
|
||||
assert drafts.c["token"].default is not None, "token needs an ORM default (uuid4)"
|
||||
|
||||
Reference in New Issue
Block a user