From 4a327b5363f089d79aab90df52685ee2e5774450 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Tue, 16 Jun 2026 05:11:17 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A7=AA=20Add=20tests=20for=20has=5Fcu?= =?UTF-8?q?rrent=5Fhead=5Fapproval=20in=20pr=5Freview=5Fmerge=5Fscheduler.?= =?UTF-8?q?py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_pr_review_merge_scheduler.py | 80 +++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tests/test_pr_review_merge_scheduler.py diff --git a/tests/test_pr_review_merge_scheduler.py b/tests/test_pr_review_merge_scheduler.py new file mode 100644 index 0000000..a7cdd0b --- /dev/null +++ b/tests/test_pr_review_merge_scheduler.py @@ -0,0 +1,80 @@ +import pytest +from scripts.ci.pr_review_merge_scheduler import has_current_head_approval + +def test_has_current_head_approval_true_from_review_state(): + pr = { + "headRefOid": "commit123", + "reviewDecision": "REVIEW_REQUIRED", + "reviews": { + "nodes": [ + { + "state": "APPROVED", + "author": {"login": "opencode-agent"}, + "commit": {"oid": "commit123"}, + } + ] + } + } + assert has_current_head_approval(pr) is True + +def test_has_current_head_approval_true_from_review_decision(): + pr = { + "headRefOid": "commit123", + "reviewDecision": "APPROVED", + "reviews": { + "nodes": [] + } + } + assert has_current_head_approval(pr) is True + +def test_has_current_head_approval_false(): + pr = { + "headRefOid": "commit123", + "reviewDecision": "REVIEW_REQUIRED", + "reviews": { + "nodes": [ + { + "state": "CHANGES_REQUESTED", + "author": {"login": "opencode-agent"}, + "commit": {"oid": "commit123"}, + } + ] + } + } + assert has_current_head_approval(pr) is False + +def test_has_current_head_approval_wrong_commit(): + pr = { + "headRefOid": "commit123", + "reviewDecision": "REVIEW_REQUIRED", + "reviews": { + "nodes": [ + { + "state": "APPROVED", + "author": {"login": "opencode-agent"}, + "commit": {"oid": "oldcommit456"}, + } + ] + } + } + assert has_current_head_approval(pr) is False + +def test_has_current_head_approval_wrong_author(): + pr = { + "headRefOid": "commit123", + "reviewDecision": "REVIEW_REQUIRED", + "reviews": { + "nodes": [ + { + "state": "APPROVED", + "author": {"login": "some-other-user"}, + "commit": {"oid": "commit123"}, + } + ] + } + } + assert has_current_head_approval(pr) is False + +def test_has_current_head_approval_missing_keys(): + pr = {} + assert has_current_head_approval(pr) is False From f3cb70e719cc2bb9683e398e0c1e4921cf235597 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Tue, 16 Jun 2026 06:47:44 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A7=AA=20Add=20tests=20for=20has=5Fcu?= =?UTF-8?q?rrent=5Fhead=5Fapproval=20in=20pr=5Freview=5Fmerge=5Fscheduler.?= =?UTF-8?q?py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit