diff options
| author | tedin7 <tommasoderosa94@gmail.com> | 2026-11-23 02:28:32 +0100 |
|---|---|---|
| committer | tedin7 <tommasoderosa94@gmail.com> | 2026-11-23 02:28:32 +0100 |
| commit | 372cf42ec2fc3f482fe33b16cec9d09313d4759d (patch) | |
| tree | 6f5fb3a3c280074215e429e48b79efe5109deef1 /tests/test_progress_dashboard.py | |
| parent | 03b09a086592a197db64d91655c6e65c30764d96 (diff) | |
progress_dashboard: count merged D3D- items from merged PR titles (BUILD-1283)
Diffstat (limited to 'tests/test_progress_dashboard.py')
| -rw-r--r-- | tests/test_progress_dashboard.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_progress_dashboard.py b/tests/test_progress_dashboard.py index dfa5e8e9c..e4e523a6b 100644 --- a/tests/test_progress_dashboard.py +++ b/tests/test_progress_dashboard.py | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | python -I tests/test_progress_dashboard.py | 3 | python -I tests/test_progress_dashboard.py |
| 4 | 4 | ||
| 5 | Every input is written here by hand (Markdown tables, JUnit XML, a CTest log, a fake work folder whose shader names | 5 | Every input is written here by hand (Markdown tables, JUnit XML, a CTest log, a fake work folder whose shader names |
| 6 | are sentinels). No game files, no GPU, no network: the GitHub path is exercised through its parsers only. | 6 | are sentinels). No game files, no GPU, no network: the GitHub path is fed synthetic gh output. |
| 7 | """ | 7 | """ |
| 8 | import json | 8 | import json |
| 9 | import os | 9 | import os |
| @@ -11,6 +11,7 @@ import subprocess | |||
| 11 | import sys | 11 | import sys |
| 12 | import tempfile | 12 | import tempfile |
| 13 | import unittest | 13 | import unittest |
| 14 | from unittest import mock | ||
| 14 | 15 | ||
| 15 | HERE = os.path.dirname(os.path.abspath(__file__)) | 16 | HERE = os.path.dirname(os.path.abspath(__file__)) |
| 16 | ROOT = os.path.dirname(HERE) | 17 | ROOT = os.path.dirname(HERE) |
| @@ -164,6 +165,26 @@ class Github(unittest.TestCase): | |||
| 164 | self.assertEqual(pd.item_ids("hash with SHA-256, write UTF-8, read OPTIONS2-1 and D3D12-3"), []) | 165 | self.assertEqual(pd.item_ids("hash with SHA-256, write UTF-8, read OPTIONS2-1 and D3D12-3"), []) |
| 165 | self.assertEqual(pd.item_ids(None), []) | 166 | self.assertEqual(pd.item_ids(None), []) |
| 166 | 167 | ||
| 168 | def test_d3d_metric_counts_merged_pull_requests_not_only_table_rows(self): | ||
| 169 | body = ("| ID | Title | Owner | PR | Status |\n|---|---|---|---|---|\n" | ||
| 170 | "| D3D-1 | a | @a | #50 | PR open |\n| D3D-2 | b | @b | #51 | PR open |\n") | ||
| 171 | merged = [{"number": n, "title": f"D3D-{n}: x", "mergedAt": "2026-11-22T10:00:00Z", "author": {"login": "x"}} | ||
| 172 | for n in (10, 11, 12)] | ||
| 173 | open_prs = [{"number": 50, "title": "D3D-1: a", "isDraft": False, "author": {"login": "x"}}, | ||
| 174 | {"number": 51, "title": "D3D-2: b", "isDraft": False, "author": {"login": "x"}}] | ||
| 175 | |||
| 176 | def fake_gh(args, timeout=60): | ||
| 177 | if args[:2] == ["pr", "list"]: | ||
| 178 | return merged if "merged" in args else open_prs | ||
| 179 | if args[:2] == ["issue", "view"]: | ||
| 180 | return {"body": body, "updatedAt": "2026-11-22T00:00:00Z"} | ||
| 181 | return [] | ||
| 182 | col = pd.Collector() | ||
| 183 | with mock.patch.object(pd, "gh_json", fake_gh), mock.patch.object(pd.shutil, "which", lambda _: "/usr/bin/gh"): | ||
| 184 | pd.collect_github(col, "o/r", "me") | ||
| 185 | m = next(m for m in col.metrics if m["id"] == "d3d12.merged") | ||
| 186 | self.assertEqual((m["numerator"], m["denominator"]), (3, 5)) | ||
| 187 | |||
| 167 | def test_merged_pull_requests_are_implemented(self): | 188 | def test_merged_pull_requests_are_implemented(self): |
| 168 | merged = [{"number": 10, "title": "D3D-1: a", "mergedAt": "2026-11-22T10:00:00Z", "author": {"login": "x"}}, | 189 | merged = [{"number": 10, "title": "D3D-1: a", "mergedAt": "2026-11-22T10:00:00Z", "author": {"login": "x"}}, |
| 169 | {"number": 12, "title": "docs: b", "mergedAt": "2026-11-22T12:00:00Z", "author": {"login": "y"}}] | 190 | {"number": 12, "title": "docs: b", "mergedAt": "2026-11-22T12:00:00Z", "author": {"login": "y"}}] |