feat(review): walkthrough/risk_verdict/test_coverage schema
This commit is contained in:
@@ -479,9 +479,9 @@ def test_parse_review_output_bare_findings_no_summary():
|
||||
|
||||
|
||||
def test_parse_review_output_empty_and_bogus():
|
||||
assert parse_review_output("") == ("", [], [], [])
|
||||
assert parse_review_output("no json here") == ("", [], [], [])
|
||||
assert parse_review_output('{"findings":[]}') == ("", [], [], [])
|
||||
assert parse_review_output("") == ("", [], [], [], [], "", "")
|
||||
assert parse_review_output("no json here") == ("", [], [], [], [], "", "")
|
||||
assert parse_review_output('{"findings":[]}') == ("", [], [], [], [], "", "")
|
||||
|
||||
|
||||
def test_parse_review_output_uses_last_json_block():
|
||||
@@ -565,6 +565,44 @@ def test_parse_review_output_bare_array_at_tail():
|
||||
assert len(fs) == 1
|
||||
|
||||
|
||||
def test_parse_review_output_extracts_walkthrough_risk_tests():
|
||||
# The 7-tuple shape carries three new top-level fields:
|
||||
# walkthrough (list[str]), risk_verdict (str), test_coverage (str).
|
||||
txt = (
|
||||
"```json\n"
|
||||
"{\n"
|
||||
' "summary": "x",\n'
|
||||
' "summary_changes": [],\n'
|
||||
' "risks": [],\n'
|
||||
' "walkthrough": ["a.py: adds X", "b.py: refactors Y"],\n'
|
||||
' "risk_verdict": "Low risk.",\n'
|
||||
' "test_coverage": "No tests for behavioral change in a.py.",\n'
|
||||
' "findings": []\n'
|
||||
"}\n"
|
||||
"```"
|
||||
)
|
||||
summary, findings, _changes, _risks, walkthrough, risk_verdict, test_coverage = (
|
||||
parse_review_output(txt)
|
||||
)
|
||||
assert summary == "x"
|
||||
assert findings == []
|
||||
assert walkthrough == ["a.py: adds X", "b.py: refactors Y"]
|
||||
assert risk_verdict == "Low risk."
|
||||
assert test_coverage == "No tests for behavioral change in a.py."
|
||||
|
||||
|
||||
def test_parse_review_output_missing_fields_default_empty():
|
||||
# Backward-compatible: the 4-tuple shape still parses fine; the new
|
||||
# fields default to empty list / empty string.
|
||||
out = parse_review_output('{"summary":"x","findings":[]}')
|
||||
summary, findings, _changes, _risks, walkthrough, risk_verdict, test_coverage = out
|
||||
assert summary == "x"
|
||||
assert findings == []
|
||||
assert walkthrough == []
|
||||
assert risk_verdict == ""
|
||||
assert test_coverage == ""
|
||||
|
||||
|
||||
def test_scan_balanced_handles_braces_in_strings():
|
||||
# The JSON scanner must not be fooled by `{` or `}` inside string literals.
|
||||
s = '{"a":"contains { and }","b":1}'
|
||||
|
||||
@@ -844,7 +844,9 @@ def test_no_surface_response_parses_as_an_empty_review():
|
||||
import ai_review
|
||||
text, usage = oc._no_surface_response("o/r", "9", "abc12345", 3)
|
||||
assert usage is None
|
||||
summary, findings, _changes, _risks = ai_review.parse_review_output(text)
|
||||
summary, findings, _changes, _risks, _walkthrough, _risk_verdict, _test_coverage = (
|
||||
ai_review.parse_review_output(text)
|
||||
)
|
||||
assert findings == []
|
||||
assert summary # non-empty, so ai_review does NOT take the salvage branch
|
||||
assert "no review surface" in summary.lower()
|
||||
@@ -854,6 +856,6 @@ def test_no_surface_response_parses_as_an_empty_review():
|
||||
def test_no_surface_response_zero_lenses_wording():
|
||||
import ai_review
|
||||
text, _ = oc._no_surface_response("o/r", "9", "abc12345", 0)
|
||||
summary, findings, _c, _r = ai_review.parse_review_output(text)
|
||||
summary, findings, _c, _r, _w, _rv, _tc = ai_review.parse_review_output(text)
|
||||
assert findings == []
|
||||
assert "after path filtering" in summary
|
||||
|
||||
Reference in New Issue
Block a user