Add production condition retrieval smoke test

This commit is contained in:
2026-08-11 14:58:28 +07:00
parent 59e6ad2d0d
commit 7ebbe1f309
38 changed files with 3752 additions and 121 deletions
@@ -227,6 +227,41 @@ def test_list_mode_skips_the_sufficiency_clarify():
assert g.generated is True
def test_list_mode_rejects_a_generated_drug_outside_candidate_set():
evidence = Evidence(
evidence_id="a__chi_dinh__0",
matched_doc_id="a__chi_dinh__0",
kind="prose",
text="Thuốc A được chỉ định điều trị bệnh X.",
score=1.0,
source_refs=(SourceRef(physical_page=100, precision="exact", printed_page=101),),
hydrated_from_parent=False,
requires_visual_check=False,
drug_id="a",
drug_name="A",
section_key="chi_dinh",
)
result = _answerable(evidence)
gen = _Generator({
"claims": [{"text": "Thuốc D điều trị bệnh X.", "citations": [1], "drug_id": "d"}],
"evidence_sufficient": True,
"clarifying_question": None,
"quick_replies": [],
})
service = GroundedAnswerService(_Routing(result), gen)
grounded = service.answer_from_result(
"Bệnh X dùng thuốc gì?",
result,
list_mode=True,
candidate_drug_ids=("a",),
)
assert grounded.answer is None
assert grounded.result.decision == EvidenceDecision.ABSTAIN
assert grounded.result.reason == "unsupported_drug"
def test_without_list_mode_the_same_evidence_does_ask_for_clarification():
"""Control for the test above: the same sufficiency payload, without
`list_mode`, must actually clarify — proving the previous test's "not