import importlib.util import unittest from pathlib import Path def load_post_patch_runner(): script_path = Path(__file__).resolve().parents[1] / "scripts" / "run_round04_post_patch_verification.py" spec = importlib.util.spec_from_file_location("run_round04_post_patch_verification", script_path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module class Round041PostPatchVerificationTests(unittest.TestCase): def test_targeted_labels_are_limited_to_review_approved_cases(self): runner = load_post_patch_runner() self.assertEqual( sorted(runner.TARGET_EXPECTATIONS.keys()), ["R04-BI-002", "R04-BI-024", "R04-BI-035", "R04-BI-036"], ) def test_report_marks_target_cases_pass_after_patch(self): runner = load_post_patch_runner() root = Path(__file__).resolve().parents[1] report = runner.build_post_patch_report(root) self.assertIn("# Round 04.1 Post-Patch Routing Verification Report", report) self.assertIn("This is not a second blind test.", report) self.assertIn("Targeted cases checked: 4", report) self.assertIn("Targeted failures: 0", report) self.assertIn("Behavior changes recorded: 5", report) self.assertIn("## Non-target Behavior Diff / Accepted Collateral Change", report) self.assertIn("### R04-BI-022", report) self.assertIn("Not a new failure.", report) self.assertIn("lightweight QPI is acceptable and IA should remain rejected", report) for case_id in ["R04-BI-002", "R04-BI-024", "R04-BI-035", "R04-BI-036"]: self.assertIn(f"### {case_id}", report) self.assertIn("status: `PASS`", report) if __name__ == "__main__": unittest.main()