diff --git a/bin/do_epic/backend/test_jira.py b/bin/do_epic/backend/test_jira.py index 1ecc75a5..8ef88099 100644 --- a/bin/do_epic/backend/test_jira.py +++ b/bin/do_epic/backend/test_jira.py @@ -188,6 +188,7 @@ class Jira(Case): 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, {"id": "12", "name": "Pause", "to": {"name": "On Hold", "statusCategory": {"key": "indeterminate"}}}], None, f"{key}'s status has no transition to a done status, only 'Start' to 'In Progress' and 'Pause' to 'On Hold': Jira lists only the transitions the account may make, so move the issue in Jira, or let the account transition issues"), ([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}"), @@ -228,8 +229,20 @@ class Jira(Case): url = ("GET", f"{ISSUES}/{key}/transitions") self.jira.answers[url] = Failure("Jira answered 503") self.assertEqual(store.finish(key), Failure(f"cannot read {key}'s transitions: Jira answered 503")) - self.jira.answers[url] = {"transitions": [{"id": 31}]} - self.assertEqual(store.finish(key), Failure(f"Jira answered {key}'s transitions in a shape other than the one it documents")) + for answer in ({"transitions": [{"id": 31}]}, ["Mark as done"], {"transitions": 5}): + with self.subTest(answer=answer): + self.jira.answers[url] = answer + self.assertEqual(store.finish(key), Failure(f"Jira answered {key}'s transitions in a shape other than the one it documents")) + + def test_a_finish_whose_issue_or_parent_jira_cannot_read_says_which(self) -> None: + store = self.new_store() + child = store.file("ABC-12", "Count the runs.", "", ()) + task = store.file(child, "Count them in the api.", "", ()) + self.jira.answers[("GET", f"{ISSUES}/{task}?fields=parent,status")] = Failure("Jira answered 503") + self.assertEqual(store.finish(task), Failure(f"cannot read {task} to finish it: Jira answered 503")) + del self.jira.answers[("GET", f"{ISSUES}/{task}?fields=parent,status")] + self.jira.answers[("GET", f"{ISSUES}/{child}?fields=parent")] = Failure("Jira answered 503") + self.assertEqual(store.finish(task), Failure(f"cannot read {child} to finish its sub-task: Jira answered 503")) def test_reads_the_sub_tasks_of_more_children_than_one_search_names(self) -> None: store = self.new_store() diff --git a/bin/do_epic/test_main.py b/bin/do_epic/test_main.py index 7cf34942..7524732c 100644 --- a/bin/do_epic/test_main.py +++ b/bin/do_epic/test_main.py @@ -14,7 +14,9 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from do_epic import chunk_prompt, main from project_config.test_project_config import configured from do_epic.backend.protocol import EpicIssue +from do_epic.config import DoEpicConfig from do_epic.epic_record import EpicRecord +from project_config.settings import Epic from agent_cycle import escalation_mark, judge, tmux from failure import Failure from loop_claude.test_loop_claude import FakeEffects, judged, Worker @@ -61,6 +63,14 @@ class DoEpicTest(unittest.TestCase): return code, out.getvalue(), err.getvalue() +class TheJiraBackend(unittest.TestCase): + def test_reads_the_epic_with_the_credentials_and_the_finish_transition_the_config_names(self) -> None: + config = DoEpicConfig(pathlib.Path("/c"), "https://acme.atlassian.net", pathlib.Path("/h/jira.env"), pathlib.Path("/h/code"), "English", "claude-opus-5-5", "rule", "Close Issue") + store, record = main.jira_backend(config, "ABC-12") + self.assertEqual((store.epic, store.env_file, store.finish_by), (Epic("https://acme.atlassian.net", "ABC-12"), pathlib.Path("/h/jira.env"), "Close Issue")) # type: ignore[attr-defined] + self.assertEqual((record.description.epic, record.description.env_file), (store.epic, store.env_file)) # type: ignore[attr-defined] + + class TheLauncher(unittest.TestCase): def test_the_repo_ships_a_do_epic_that_prints_its_help(self) -> None: launcher = pathlib.Path(__file__).resolve().parents[1] / "do-epic"