From 6be08a3834a44aec38eba20609c358e216484da4 Mon Sep 17 00:00:00 2001 From: kert Date: Mon, 16 Nov 2026 13:29:01 -0500 Subject: [PATCH] fix(llm): match dossier and valuation tests to current families CCM is curated, and the book has no planned family left, so the 404 status test injects one. 99213 and 99214 expand to the office-visit family; the concurrency test counts the asked code's own rows. --- tests/llm/test_evidence.py | 13 ++++++++----- tests/llm/test_policy_api.py | 15 +++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/llm/test_evidence.py b/tests/llm/test_evidence.py index 3fa18e2..683d58c 100644 --- a/tests/llm/test_evidence.py +++ b/tests/llm/test_evidence.py @@ -581,8 +581,9 @@ class TestConcurrentChats: con.execute("CREATE SCHEMA pfs") con.execute(f"CREATE TABLE pfs.rvu ({RVU_COLS})") con.execute(f"CREATE TABLE pfs.rvu_proposed ({PROPOSED_COLS})") - # two unfamilied codes with different row counts, so a swapped - # result set is visible as a wrong count + # Two codes in one family, with different row counts. A question + # names one code and the family comes with it; the asked code's + # own rows are what shows a swapped result set. con.executemany( "INSERT INTO pfs.rvu VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", [ @@ -630,15 +631,17 @@ class TestConcurrentChats: opens.append(a) return real_connect(*a, **kw) - expected = {"99213": 1, "99214": 3} + # 99214 is inserted for three years; a year with no pfs.rules + # entry is not priced, so the asked code contributes two rows. + expected = {"99213": 1, "99214": 2} questions = ["What does 99213 pay?", "What does 99214 pay?"] def one(i): q = questions[i % 2] + want = "99213" if i % 2 == 0 else "99214" ev = valuation_evidence(q, cfg) assert ev is not None, "valuation dropped under concurrency" - (code,) = ev.codes - return code, len(ev.rows) + return want, sum(1 for r in ev.rows if r.code == want) with patch("llm.evidence.duckdb.connect", counting_connect): with ThreadPoolExecutor(max_workers=8) as pool: diff --git a/tests/llm/test_policy_api.py b/tests/llm/test_policy_api.py index 6c1dbaa..559974e 100644 --- a/tests/llm/test_policy_api.py +++ b/tests/llm/test_policy_api.py @@ -261,11 +261,18 @@ def test_unknown_section_404(client): def test_no_dossier_404_with_status(client, monkeypatch): - r = client.get(URL.format("header"), params={"family": "CCM"}) + # Every book family is curated now, so "planned" has to be injected. + from pfs.book import load_book + + real_book = load_book() + monkeypatch.setattr( + "pfs.book.load_book", lambda *a, **k: {**real_book, "ZZZ-PLAN": object()} + ) + r = client.get(URL.format("header"), params={"family": "ZZZ-PLAN"}) assert r.status_code == 404 d = r.json()["detail"] - assert d["status"] == "planned" and d["family"] == "CCM" - assert d["message"] == "No dossier is built for CCM yet." + assert d["status"] == "planned" and d["family"] == "ZZZ-PLAN" + assert d["message"] == "No dossier is built for ZZZ-PLAN yet." from pfs.curated import load_curated @@ -380,7 +387,7 @@ def test_fact_endpoint(client): assert r.status_code == 404 and r.json()["detail"]["message"] == "unknown fact" assert client.get("/api/policy/fact", params={**HV, "id": "x"}).status_code == 422 r = client.get("/api/policy/fact", params={"family": "CCM", "id": "F1"}) - assert r.status_code == 404 and r.json()["detail"]["status"] == "planned" + assert r.status_code == 404 and r.json()["detail"]["status"] == "curated" def test_load_slice_matches_http(replica, client):