Answer product-owner round 1: 0 🔴, 4 🟡 (0 misread); move through the open status, refuse open-epic without a branch, tell a conflict from git's other failures
This commit is contained in:
@@ -7,6 +7,7 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import typing
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
@@ -983,6 +984,22 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
||||
self.assertIn(f"cannot remove {self.file}: Permission denied", err)
|
||||
|
||||
|
||||
class StepwiseStore:
|
||||
"""A store whose workflow reaches each status in `after` only from the status it names there; every other call is the wrapped store's."""
|
||||
|
||||
def __init__(self, store: typing.Any, after: dict[str, str]) -> None:
|
||||
self.store, self.after = store, after
|
||||
|
||||
def __getattr__(self, name: str) -> typing.Any:
|
||||
return getattr(self.store, name)
|
||||
|
||||
def move_issue(self, key: str, status: str) -> None | Failure:
|
||||
now = self.store.within(key).status
|
||||
if status in self.after and now not in (status, self.after[status]):
|
||||
return Failure(f"{key} has no transition to {status!r} from its status {now!r}")
|
||||
return self.store.move_issue(key, status)
|
||||
|
||||
|
||||
class AnEpicsWorkingBranch(DoEpicTest):
|
||||
"""A chunk in a repo whose config sets `epic-branch`, so its pull request goes into the branch ABC-12."""
|
||||
|
||||
@@ -1022,7 +1039,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
self.assertEqual(self.git_calls, [])
|
||||
|
||||
def test_a_default_branch_that_conflicts_stops_the_loop_for_a_person_and_records_no_base(self) -> None:
|
||||
stop = main.epic_based("ABC-20", self.checkout, self.epic_run(self.with_git(FakeEffects(), rev_list="1\n", merge_tree=Failure("CONFLICT"))))
|
||||
stop = main.epic_based("ABC-20", self.checkout, self.epic_run(self.with_git(FakeEffects(), rev_list="1\n", merge_tree=Failure("git merge-tree --write-tree origin/ABC-12 origin/main: "))))
|
||||
self.assertEqual(stop, main.Stop(1, f"cannot ready the epic's working branch ABC-12 in {self.checkout} for ABC-20: origin/main doesn't merge into origin/ABC-12 cleanly, so a person merges it: check ABC-12 out, run `git merge origin/main`, resolve the conflicts and push; once that is settled, run `do-epic ABC-12` to start the chunk again"))
|
||||
self.assertNotIn("config", [args[0] for args, _ in self.git_calls])
|
||||
|
||||
@@ -1032,6 +1049,12 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
self.assertIn("no origin/HEAD", stop.reason)
|
||||
self.assertEqual(len(self.git_calls), 1)
|
||||
|
||||
def test_a_chunk_whose_working_branch_cannot_be_readied_leaves_its_issue_unstarted(self) -> None:
|
||||
code, _, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], self.with_git(FakeEffects(), rev_list="1\n", merge_tree=Failure("git merge-tree --write-tree origin/ABC-12 origin/main: ")), MODELS)
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn("cannot ready the epic's working branch ABC-12", err)
|
||||
self.assertEqual(self.store.writes, [])
|
||||
|
||||
def test_its_issue_moves_as_the_pull_request_opens_and_merges_and_no_person_merges_it(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
self.forges = [awaiting(), awaiting(), awaiting(decision="APPROVED")]
|
||||
@@ -1058,6 +1081,19 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
self.assertEqual(main.handed_on("ABC-20", self.epic_run(FakeEffects(windows="")), in_repo=True, to_epic_branch=True).code, 0)
|
||||
self.assertTrue(self.store.issues[0].done)
|
||||
|
||||
def test_an_issue_whose_workflow_reaches_the_merged_status_only_through_the_open_status_moves_through_it(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
epic = self.epic_run(FakeEffects(windows=""))
|
||||
stepwise = StepwiseStore(self.store, {"Release Ready": "Code Review"})
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
stop = main.handed_on("ABC-20", dataclasses.replace(epic, store=stepwise), in_repo=True, to_epic_branch=True)
|
||||
self.assertEqual(stop.code, 0, stop.reason)
|
||||
self.assertEqual(self.store.writes, ["move ABC-20 to Code Review", "move ABC-20 to Release Ready"])
|
||||
# An issue the open status doesn't lead on from stops on the move it asked for.
|
||||
stuck = StepwiseStore(self.store, {"Release Ready": "QA", "Code Review": "QA"})
|
||||
stop = main.handed_on("ABC-22", dataclasses.replace(epic, store=stuck), in_repo=True, to_epic_branch=True)
|
||||
self.assertTrue(stop.reason.startswith("the chunk finished, but its issue could not move to 'Release Ready': ABC-22 has no transition to 'Release Ready'"), stop.reason)
|
||||
|
||||
def test_an_issue_that_cannot_move_to_the_merged_status_stops_and_says_what_to_do(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
self.store.fails = "Jira answered 503"
|
||||
|
||||
Reference in New Issue
Block a user