from iac_secfix_agents.llm import parse_fix_candidate def test_parse_fix_candidate_from_json(): candidate, ok = parse_fix_candidate( '{"patch":"diff","fixed_file":"resource \\"x\\" \\"y\\" {}","resolved_policy_ids":["CKV_X_1"],"explanation":"ok","verification_commands":[],"risk_notes":[],"requires_human_approval":true}' ) assert ok assert candidate is not None assert candidate.resolved_policy_ids == ["CKV_X_1"] def test_parse_fix_candidate_from_wrapped_text(): candidate, ok = parse_fix_candidate( 'Here is the JSON: {"patch":"","fixed_file":"kind: Pod\\n","resolved":["CKV_K8S_8"],"summary":"fixed"}' ) assert ok assert candidate is not None assert candidate.resolved_policy_ids == ["CKV_K8S_8"]