Answer product-owner round 1: 1 🔴, 3 🟡 (1 misread); finish a sub-task too, name the transition in the config where several close an issue, say how to start the blocked chunks after a refused move

This commit is contained in:
2026-11-18 23:38:02 +01:00
parent 42cff3a8a7
commit 720b558bbf
9 changed files with 92 additions and 34 deletions
+34 -11
View File
@@ -45,6 +45,8 @@ class FakeJira:
answers: dict[tuple[str, str], object] = dataclasses.field(default_factory=dict)
calls: list[tuple[str, str]] = dataclasses.field(default_factory=list)
comments: dict[str, list[object]] = dataclasses.field(default_factory=dict)
# The ID of each transition made.
transitioned: list[str] = dataclasses.field(default_factory=list)
# The transitions Jira offers an issue that isn't done.
workflow: list[dict[str, object]] = dataclasses.field(default_factory=lambda: [{"id": "31", "name": "Mark as done", "to": DONE}])
@@ -68,6 +70,7 @@ class FakeJira:
if method == "POST" and (held := next((issue for issue in self.issues if url == f"{ISSUES}/{issue['key']}/transitions"), None)):
assert isinstance(body, dict)
held["fields"]["status"] = DONE # type: ignore[index]
self.transitioned.append(body["transition"]["id"])
return None
if method == "POST" and url == ISSUES:
return self.created(body)
@@ -178,26 +181,46 @@ class Jira(Case):
self.assertIsNone(store.finish(key))
self.assertNotIn(("GET", f"{ISSUES}/{key}/transitions"), self.jira.calls)
def test_a_finish_names_why_no_one_move_closes_the_issue(self) -> None:
store = self.new_store()
key = store.file("ABC-12", "Count the runs.", "", ())
wont = {"name": "Closed", "statusCategory": {"key": "done"}}
def test_a_finish_names_why_no_move_closes_the_issue(self) -> None:
key = self.new_store().file("ABC-12", "Count the runs.", "", ())
closed = {"name": "Closed", "statusCategory": {"key": "done"}}
start = {"id": "11", "name": "Start", "to": {"name": "In Progress", "statusCategory": {"key": "indeterminate"}}}
for workflow, reason in (
([start], f"{key}'s status has no transition to a done status, only 'Start' to 'In Progress'"),
([], f"{key}'s status has no transition to a done status"),
([{"id": "31", "name": "Mark as done", "to": DONE}, {"id": "41", "name": "Won't do", "to": wont}], f"{key}'s status has more than one transition to a done status, 'Mark as done' to 'Done' and \"Won't do\" to 'Closed'"),
both = [{"id": "31", "name": "Mark as done", "to": DONE}, {"id": "41", "name": "Close", "to": closed}]
config = " in `jira-finish-transition`, in ~/.claude-projects/do-epic/config.toml"
for workflow, named, reason in (
([start], None, f"{key}'s status has no transition to a done status, only 'Start' to 'In Progress': Jira lists only the transitions the account may make, so move the issue in Jira, or let the account transition issues"),
([], None, f"{key}'s status has no transition to a done status: Jira lists only the transitions the account may make, so move the issue in Jira, or let the account transition issues"),
(both, None, f"{key}'s status has more than one transition to a done status, 'Mark as done' to 'Done' and 'Close' to 'Closed': name the one to use{config}"),
(both, "Resolve", f"{key}'s status has no transition called 'Resolve' to a done status, only 'Mark as done' to 'Done' and 'Close' to 'Closed': correct `jira-finish-transition`, in ~/.claude-projects/do-epic/config.toml"),
([start], "Close", f"{key}'s status has no transition to a done status, only 'Start' to 'In Progress': Jira lists only the transitions the account may make, so move the issue in Jira, or let the account transition issues"),
):
with self.subTest(workflow=workflow):
with self.subTest(workflow=workflow, named=named):
self.jira.workflow = workflow # type: ignore[assignment]
self.assertEqual(store.finish(key), Failure(f"{reason}: move the issue in Jira, or change the workflow so that one move closes it"))
self.assertEqual(JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, named).finish(key), Failure(reason))
self.assertEqual(self.jira.issues[0]["fields"]["status"], TO_DO) # type: ignore[index]
def test_finishes_by_the_transition_the_config_names_where_several_lead_to_a_done_status(self) -> None:
key = self.new_store().file("ABC-12", "Count the runs.", "", ())
self.jira.workflow = [{"id": "31", "name": "Resolve", "to": DONE}, {"id": "41", "name": "Close", "to": {"name": "Closed", "statusCategory": {"key": "done"}}}]
self.assertIsNone(JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, "Close").finish(key))
self.assertEqual(self.jira.calls[-1], ("POST", f"{ISSUES}/{key}/transitions"))
self.assertEqual(self.jira.transitioned, ["41"])
def test_refuses_to_finish_a_sub_task_of_an_issue_that_is_no_child_of_the_epic_or_an_issue_without_a_parent(self) -> None:
store = self.new_store()
for key, parent in (("ABC-50", "ABC-60"), ("ABC-60", "ABC-61"), ("ABC-61", None)):
fields = {"summary": "Other.", "description": None, "labels": [], "assignee": None, "status": TO_DO, "parent": {"key": parent} if parent else None, "issuelinks": []}
self.jira.issues.append({"key": key, "fields": fields})
for key in ("ABC-50", "ABC-61"):
with self.subTest(key=key):
self.assertEqual(store.finish(key), Failure(f"{key} is not one of the child issues of the epic ABC-12, so it cannot be finished"))
self.assertNotIn("POST", [method for method, _ in self.jira.calls])
def test_a_finish_jira_refuses_says_so_and_that_the_issue_may_have_moved(self) -> None:
store = self.new_store()
key = store.file("ABC-12", "Count the runs.", "", ())
self.jira.answers[("POST", f"{ISSUES}/{key}/transitions")] = Failure("Jira answered 400: Resolution is required")
self.assertEqual(store.finish(key), Failure(f"cannot move {key} to done: Jira answered 400: Resolution is required; the issue may have moved all the same: read it in Jira before moving it again"))
self.assertEqual(store.finish(key), Failure(f"cannot move {key} to done: Jira answered 400: Resolution is required; unless Jira refused the request, {key} may be done: read it in Jira before moving it again"))
def test_a_finish_whose_transitions_jira_cannot_give_or_gives_in_another_shape_fails(self) -> None:
store = self.new_store()