From 3dba8aabbfe7e741e9858b03064c2a2bd58a0de8 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 28 Jun 2026 10:00:37 +0700 Subject: [PATCH] test: pin empty selection_reason passthrough in build_certificate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The _make_scored() helper in test_certificate.py uses 'or' short-circuit (selection_reason or ['default']), so passing selection_reason=[] silently becomes the default value — no test has ever exercised the empty-list path. Added test_empty_selection_reason_passthrough that bypasses the helper and directly constructs ScoredCandidate(selection_reason=[]) to verify: 1. build_certificate() passes the empty list through unchanged 2. cert['selection_reason'] == [] (the JSON schema allows this — no minItems) This is the final audit-identified gap from the pre-synthesis quality sprint. --- tests/test_certificate.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_certificate.py b/tests/test_certificate.py index 327d3053..e6f18425 100644 --- a/tests/test_certificate.py +++ b/tests/test_certificate.py @@ -152,3 +152,17 @@ def test_all_required_keys_present(self): def test_returns_dict(self): cert = build_certificate(_make_scored(), {}, []) assert isinstance(cert, dict) + + def test_empty_selection_reason_passthrough(self): + # The _make_scored() helper uses `or` so it cannot test selection_reason=[]. + # This test bypasses the helper to verify the production code handles an empty list. + # The JSON schema allows an empty array (no minItems constraint). + scored = ScoredCandidate( + candidate=_CANDIDATE, + features=_FEATURES, + scores=_SCORES, + selection_reason=[], + known_failure_modes=["No wet-lab assay has been run."], + ) + cert = build_certificate(scored, {}, []) + assert cert["selection_reason"] == []