Pass over an item whose pull request awaits a person's merge, and hold a sentence about several named things to each
CI / tests (pull_request) Failing after 3m42s
CI / tests (pull_request) Failing after 3m42s
This commit is contained in:
+26
-1
@@ -1,4 +1,5 @@
|
||||
import itertools
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
import typing
|
||||
@@ -6,7 +7,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from forge.pulls import CheckFailed, checks_now, checks_passed, open_pull, Pending, POLL_SECONDS, required_checks, WAIT_SECONDS
|
||||
from forge.pulls import CheckFailed, checks_now, checks_passed, open_pull, Pending, POLL_SECONDS, ready_pulls, ReadyPull, required_checks, WAIT_SECONDS
|
||||
from failure import Failure
|
||||
from forge.commands import forge_of, gitea, url_beside
|
||||
|
||||
@@ -138,3 +139,27 @@ class ChecksPassed(unittest.TestCase):
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
SHA = "a" * 40
|
||||
GITEA_PULL = {"number": 7, "html_url": "https://gitea.example/o/r/pulls/7", "title": "Do 7", "head": {"sha": SHA, "repo": {"full_name": "o/r"}}, "base": {"repo": {"full_name": "o/r"}}}
|
||||
|
||||
|
||||
class ReadyPulls(unittest.TestCase):
|
||||
def test_lists_on_gh_each_open_pull_request_from_origins_own_branches_that_is_no_draft(self):
|
||||
commands: list[list[str]] = []
|
||||
listed = f"7\thttps://github.com/o/r/pull/7\t{SHA}\tfalse\tfalse\n8\thttps://github.com/o/r/pull/8\t{SHA}\ttrue\tfalse\n9\thttps://github.com/o/r/pull/9\t{SHA}\tfalse\ttrue\n"
|
||||
self.assertEqual(ready_pulls("gh", lambda command: commands.append(command) or listed), [ReadyPull("7", "https://github.com/o/r/pull/7", SHA)])
|
||||
self.assertEqual(commands[0][:5], ["gh", "pr", "list", "--limit", "100"])
|
||||
|
||||
def test_leaves_out_on_gh_a_row_whose_head_is_no_commit_id(self):
|
||||
self.assertEqual(ready_pulls("gh", lambda command: "7\thttps://github.com/o/r/pull/7\t--upload-pack=x\tfalse\tfalse\n"), [])
|
||||
|
||||
def test_lists_on_tea_each_open_pull_request_from_origins_own_branches_whose_title_marks_no_draft(self):
|
||||
fork = {**GITEA_PULL, "number": 8, "head": {"sha": SHA, "repo": {"full_name": "other/r"}}}
|
||||
draft = {**GITEA_PULL, "number": 9, "title": "wip: Do 9"}
|
||||
self.assertEqual(ready_pulls("tea", lambda command: json.dumps([GITEA_PULL, fork, draft])), [ReadyPull("7", "https://gitea.example/o/r/pulls/7", SHA)])
|
||||
|
||||
def test_fails_where_the_forge_cannot_list_them(self):
|
||||
self.assertEqual(ready_pulls("gh", lambda command: Failure("gh: no network")).reason, "gh: no network")
|
||||
self.assertEqual(ready_pulls("tea", lambda command: LONG).reason, f"tea api listed pull requests in a shape that can't be read: {LONG[:200]}")
|
||||
|
||||
Reference in New Issue
Block a user