diff --git a/bin/do_epic/backend/contract.py b/bin/do_epic/backend/contract.py index 3dcdf92a..8a5ef48b 100644 --- a/bin/do_epic/backend/contract.py +++ b/bin/do_epic/backend/contract.py @@ -203,12 +203,6 @@ class EpicStoreContract: self.assertEqual([store.move_issue_by(task, self.transition, ("Done",)), store.move_issue_by(child, self.transition, ("Done",))], ["Done", "Done"]) self.assertEqual({issue.key: (issue.status, issue.done) for issue in self.issues(store)}, {child: ("Done", True), task: ("Done", True)}) - def test_makes_no_move_by_a_transition_that_leads_to_another_status_than_those_asked_for(self) -> None: - store = self.new_store() - child = self.filed(store, store.epic_key, "Count the runs.") - self.assertIsInstance(store.move_issue_by(child, self.transition, ("Release Ready",)), Failure) - self.assertEqual([(issue.status, issue.done) for issue in self.issues(store)], [("To Do", False)]) - def test_leaves_an_issue_already_at_a_status_asked_for_where_it_is(self) -> None: store = self.new_store() child = self.filed(store, store.epic_key, "Count the runs.") diff --git a/bin/do_epic/backend/fake.py b/bin/do_epic/backend/fake.py index fbd3a59f..377cfff4 100644 --- a/bin/do_epic/backend/fake.py +++ b/bin/do_epic/backend/fake.py @@ -127,20 +127,17 @@ class MemoryEpic: return None def move_issue_by(self, key: str, transition: str, to: tuple[str, ...]) -> str | Failure: - # The fake holds no workflow: a transition leads to the status of its own name. + # The fake holds no workflow, so it cannot tell where a transition leads: each leads to the first status asked for. if self.fails: return Failure(self.fails) issue = self.within(key) if issue is None: return no_child(self.epic_key, key, "moved") - accepted = {name.casefold() for name in to} - if issue.status.casefold() in accepted: + if issue.status.casefold() in {name.casefold() for name in to}: return issue.status - if transition.casefold() not in accepted: - return Failure(f"the transition {transition!r} leads {key} to the status {transition!r}, not to {' or '.join(repr(name) for name in to)}") - self.change(key, status=transition, done=transition.casefold() == "done") + self.change(key, status=to[0], done=to[0].casefold() == "done") self.writes.append(f"move {key} by {transition}") - return transition + return to[0] def finish_issue(self, key: str) -> None | Failure: if self.fails: diff --git a/bin/do_epic/test_parent_moves.py b/bin/do_epic/test_parent_moves.py index d26fb53e..73b4efa3 100644 --- a/bin/do_epic/test_parent_moves.py +++ b/bin/do_epic/test_parent_moves.py @@ -69,10 +69,9 @@ class MovingAParentWhoseSubTasksAPersonFiled(unittest.TestCase): self.assertEqual(self.moves(family(issue("ABC-30", status="Release Ready"), ours))[0], ["move ABC-20 by Release Ready"]) self.assertEqual(self.moves(family(issue("ABC-30", done=True), ours))[0], ["finish ABC-20"]) - def test_a_landed_transition_that_leads_to_no_unblocking_status_is_not_made(self) -> None: - writes, after, refused = self.moves(family(issue("ABC-30", status="Release Ready")), landed_by="Code Review") - self.assertEqual((writes, after["ABC-20"]), ([], ("In Progress", False))) - self.assertEqual(refused, ["ABC-20's sub-tasks have all landed, but it did not move by 'Code Review', the transition `jira-sub-tasks-landed-transition` names: the transition 'Code Review' leads ABC-20 to the status 'Code Review', not to 'Release Ready' or 'Teach & Learn'; move it in Jira"]) + def test_a_landed_transition_named_unlike_its_status_moves_the_parent_to_an_unblocking_status(self) -> None: + writes, after, refused = self.moves(family(issue("ABC-30", status="Teach & Learn")), landed_by="Mark ready") + self.assertEqual((writes, after["ABC-20"], refused), (["move ABC-20 by Mark ready"], ("Release Ready", False), [])) def test_a_move_jira_refuses_is_answered_with_its_reason_and_the_other_parents_still_move(self) -> None: issues = [*family(issue("ABC-30", status="Release Ready")), *family(issue("ABC-31", done=True), parent=issue("ABC-21")), *family(issue("ABC-32", done=True), parent=issue("ABC-22"))]