import unittest from reviewer_already_landed_classification import ( # noqa: E402 ALREADY_LANDED_ELIGIBILITY_CLASS, assess_already_landed_classification_report, ) class TestAlreadyLandedClassification(unittest.TestCase): def test_non_landed_report_passes(self): result = assess_already_landed_classification_report( "Selected the next eligible PR: PR #286." ) self.assertTrue(result["proven"]) self.assertFalse(result["landed_context"]) def test_oldest_eligible_pr_on_landed_blocks(self): result = assess_already_landed_classification_report( "PR is already landed.\n" "Oldest eligible PR: PR #278." ) self.assertFalse(result["proven"]) self.assertTrue(result["block"]) def test_next_eligible_pr_on_landed_blocks(self): result = assess_already_landed_classification_report( "Ancestor proof: passed\n" "Selected the next eligible PR: PR #278." ) self.assertFalse(result["proven"]) def test_eligible_for_review_on_landed_blocks(self): result = assess_already_landed_classification_report( "Already landed on master and eligible for review next." ) self.assertFalse(result["proven"]) def test_proper_landed_wording_passes(self): result = assess_already_landed_classification_report( "Oldest open PR requiring action: PR #278\n" f"Eligibility class: {ALREADY_LANDED_ELIGIBILITY_CLASS}\n" "Candidate head SHA: abc123\n" "Reviewed head SHA: none\n" "Queue blocked by already-landed PR requiring reconciliation", selected_pr_already_landed=True, ) self.assertTrue(result["proven"]) def test_pinned_reviewed_head_without_validation_blocks(self): result = assess_already_landed_classification_report( "Already landed.\n" "Pinned reviewed head: abc123def456", selected_pr_already_landed=True, ) self.assertFalse(result["proven"]) def test_wrong_eligibility_class_blocks(self): result = assess_already_landed_classification_report( "Already landed.\n" "Eligibility class: REVIEW_ELIGIBLE", selected_pr_already_landed=True, ) self.assertFalse(result["proven"]) def test_missing_queue_blocker_blocks(self): result = assess_already_landed_classification_report( f"Eligibility class: {ALREADY_LANDED_ELIGIBILITY_CLASS}\n" "Candidate head SHA: abc123\n" "Reviewed head SHA: none", selected_pr_already_landed=True, ) self.assertFalse(result["proven"]) def test_exported_from_review_proofs(self): from review_proofs import assess_already_landed_classification_report as exported self.assertTrue(callable(exported)) if __name__ == "__main__": unittest.main()