feat(api): wire POST /npc/speak (422 unknown npc, 502 model error)

This commit is contained in:
2026-07-10 12:22:07 -05:00
parent 004cc21724
commit 0c3d64d068
3 changed files with 106 additions and 4 deletions

View File

@@ -31,7 +31,15 @@ def test_health_ok():
def test_every_role_endpoint_accepts_a_valid_canon_log():
for path in ROLE_ENDPOINTS:
r = client.post(path, json={"canon_log": VALID_LOG})
if path == "/npc/speak":
# /npc/speak has additional required fields
body = {
"canon_log": VALID_LOG, "npc_id": "brannoc_thane",
"disposition": 0, "available_moves": [], "utterance": "test"
}
else:
body = {"canon_log": VALID_LOG}
r = client.post(path, json=body)
assert r.status_code == 200, f"{path} rejected a valid log: {r.text}"
@@ -39,7 +47,15 @@ def test_every_role_endpoint_rejects_an_invalid_canon_log():
bad = json.loads(json.dumps(VALID_LOG))
bad["player"]["luck"] = 5 # §7 leak
for path in ROLE_ENDPOINTS:
r = client.post(path, json={"canon_log": bad})
if path == "/npc/speak":
# /npc/speak has additional required fields
body = {
"canon_log": bad, "npc_id": "brannoc_thane",
"disposition": 0, "available_moves": [], "utterance": "test"
}
else:
body = {"canon_log": bad}
r = client.post(path, json=body)
assert r.status_code == 422, f"{path} accepted an invalid log"
assert "canon_log_errors" in r.json()["detail"]