From 1afc0e7de256925ce3a7a922ff4b26f3293fb8eb Mon Sep 17 00:00:00 2001 From: Pratham Pansare <145864145+Pratham2511@users.noreply.github.com> Date: Sat, 10 Oct 2026 23:03:02 +0530 Subject: [PATCH 1/2] test: cover linked PR state parsing Add direct unittest coverage for missing timeline data, null nodes, PRs under subject and source, and entries without a state. Assert exact outputs to verify valid states remain in timeline order. --- scripts/test_radar.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/scripts/test_radar.py b/scripts/test_radar.py index 8d00527..65d4dd0 100644 --- a/scripts/test_radar.py +++ b/scripts/test_radar.py @@ -34,6 +34,39 @@ def comment(body, **overrides): return base +class LinkedPRStatesTests(unittest.TestCase): + def test_issue_without_timeline_items_returns_no_states(self): + self.assertEqual(radar.linked_pr_states({}), []) + + def test_null_nodes_are_skipped(self): + timeline = { + "nodes": [ + None, + {"subject": {"state": "CLOSED"}}, + None, + {"source": {"state": "OPEN"}}, + None, + ] + } + self.assertEqual(radar.linked_pr_states(issue(timelineItems=timeline)), ["CLOSED", "OPEN"]) + + def test_subject_and_source_prs_return_states_in_order(self): + timeline = {"nodes": [{"subject": {"state": "OPEN"}}, {"source": {"state": "MERGED"}}]} + self.assertEqual(radar.linked_pr_states(issue(timelineItems=timeline)), ["OPEN", "MERGED"]) + + def test_nodes_without_state_are_skipped(self): + timeline = { + "nodes": [ + {"subject": {"state": "OPEN"}}, + {"subject": {"title": "PR without a state"}}, + {}, + {"source": {"title": "Another PR without a state"}}, + {"source": {"state": "MERGED"}}, + ] + } + self.assertEqual(radar.linked_pr_states(issue(timelineItems=timeline)), ["OPEN", "MERGED"]) + + class AvailabilityTests(unittest.TestCase): def test_open_unassigned_recent_issue_is_available(self): self.assertTrue(radar.issue_is_available(issue(), SINCE)) From 7d97f6aa71e1bab25a5343071900d193a343ef9d Mon Sep 17 00:00:00 2001 From: Tanbir Hossain Ramim <96797470+TanbirRamim@users.noreply.github.com> Date: Sat, 10 Oct 2026 20:47:53 +0200 Subject: [PATCH 2/2] test: a mention from another issue keeps the issue listed --- scripts/test_radar.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/test_radar.py b/scripts/test_radar.py index 65d4dd0..ac2b9d4 100644 --- a/scripts/test_radar.py +++ b/scripts/test_radar.py @@ -66,6 +66,13 @@ def test_nodes_without_state_are_skipped(self): } self.assertEqual(radar.linked_pr_states(issue(timelineItems=timeline)), ["OPEN", "MERGED"]) + def test_mention_from_another_issue_keeps_issue_available(self): + # The query only selects PullRequest fields, so an issue that merely + # mentions this one comes back as an empty source and must not hide it. + timeline = {"nodes": [{"source": {}}, {"subject": {}}]} + self.assertEqual(radar.linked_pr_states(issue(timelineItems=timeline)), []) + self.assertTrue(radar.issue_is_available(issue(timelineItems=timeline), SINCE)) + class AvailabilityTests(unittest.TestCase): def test_open_unassigned_recent_issue_is_available(self):