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}'
|
||||
|
||||
Reference in New Issue
Block a user