Answer stability round 1: 0 🔴, 6 🟡 (0 misread); share the finish settings' checks with the project config, and test the finishing chunk's language, unread issues, cap, lock and backend
This commit is contained in:
@@ -5,14 +5,17 @@ import sys
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from do_epic.test_main import Description, DoEpicTest, MODELS, UNREAD
|
||||
from do_epic.test_main import Description, DESCRIPTION, DoEpicTest, MODELS, UNREAD
|
||||
from do_epic.config import DoEpicConfig, load
|
||||
from do_epic.epic_record import EpicRecord
|
||||
from failure import Failure
|
||||
from loop_claude.test_loop_claude import FakeEffects, judged, Worker
|
||||
from do_epic import findings, finish, main
|
||||
from do_epic import findings, finish, main, scheduler
|
||||
from project_config.settings import Finish
|
||||
from do_epic.test_scheduler import issue
|
||||
from do_epic.backend.fake import MemoryEpic
|
||||
from loop_state.paths import paths_from
|
||||
from claude_code.session import session_named
|
||||
|
||||
LAUNCHER = pathlib.Path("/b/do-epic")
|
||||
REVIEWED = [issue("ABC-20", "repo:api", done=True), issue("ABC-21", "do-epic-claude", done=True), issue("ABC-30", "repo:api", "do-epic-release-review", done=True)]
|
||||
@@ -66,6 +69,7 @@ class ClosingTheEpic(DoEpicTest):
|
||||
self.store = MemoryEpic("ABC-12", self.issues)
|
||||
|
||||
def backend(self, config: object, key: str) -> tuple[MemoryEpic, EpicRecord]:
|
||||
self.assertIsInstance(config, DoEpicConfig)
|
||||
self.store.issues = list(self.issues)
|
||||
return self.store, EpicRecord(Description(self.description)) # type: ignore[arg-type]
|
||||
|
||||
@@ -82,6 +86,21 @@ class ClosingTheEpic(DoEpicTest):
|
||||
self.assertEqual(self.store.comments, {"ABC-12": ["## Shipped\n\napi: the import."]})
|
||||
self.assertIs(self.store.done, True)
|
||||
|
||||
def test_refuses_an_epic_that_is_closed_already(self) -> None:
|
||||
self.store.done = True
|
||||
code, _, err = self.close()
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn("cannot close the epic ABC-12: it is closed already, so its summary is posted\n", err)
|
||||
self.assertEqual(self.store.comments, {})
|
||||
|
||||
def test_the_jira_backend_closes_an_epic_by_the_transition_the_settings_name(self) -> None:
|
||||
with open(self.home / ".claude-projects/do-epic/config.toml", "a", encoding="utf-8") as settings:
|
||||
settings.write('jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
||||
config = load(self.home)
|
||||
assert isinstance(config, DoEpicConfig), config
|
||||
store, _ = main.jira_backend(config, "ABC-12")
|
||||
self.assertEqual(store.finish, Finish("Mark as done", "Done")) # type: ignore[attr-defined]
|
||||
|
||||
def test_refuses_while_an_issue_is_open(self) -> None:
|
||||
self.issues.append(issue("ABC-31", "repo:api"))
|
||||
code, _, err = self.close()
|
||||
@@ -169,13 +188,41 @@ class TheFinishingChunk(DoEpicTest):
|
||||
self.assertIn("Finish the epic ABC-12", streamed)
|
||||
self.assertIn("`/b/do-epic ABC-12 --close-epic`", streamed)
|
||||
self.assertIn("From the epic ABC-12's description:\n## Goals\nShip the import.", streamed)
|
||||
self.assertIn("write a summary in English, the epic's language", streamed)
|
||||
self.assertTrue((self.home / ".local/state/do-epic/ABC-12").is_dir())
|
||||
|
||||
def test_a_worker_that_resumes_is_told_the_task_as_the_epic_now_stands(self) -> None:
|
||||
self.issues = list(REVIEWED)
|
||||
transcripts = paths_from(self.home).claude_code_transcripts
|
||||
worker = Worker(transcripts.parent)
|
||||
session = session_named("A ABC-12 do-epic ABC-12", transcripts)
|
||||
(transcripts / "-fake").mkdir(parents=True)
|
||||
(transcripts / "-fake" / f"{session.id}.jsonl").write_text("{}\n", encoding="utf-8")
|
||||
fake = FakeEffects(streams=[worker], claude=[judged("finished")], git=UNREAD, windows="ABC-12\t0\t@9\n")
|
||||
code, _, err = self.run_main(["--chunk", "ABC-12", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 0, err)
|
||||
args = [what for seam, what in fake.calls if seam == "stream_claude"][0]
|
||||
self.assertIn("--resume", args)
|
||||
self.assertIn("so it may have changed since you began. It is now:\n\nFinish the epic ABC-12", " ".join(args))
|
||||
self.assertIn("`/b/do-epic ABC-12 --close-epic`", " ".join(args))
|
||||
|
||||
def test_stops_where_the_epics_issues_cannot_be_read_or_its_lock_cannot_be_taken(self) -> None:
|
||||
self.issues = [issue("ABC-20", "do-epic-claude", done=True)]
|
||||
(self.home / ".local/state/do-epic/ABC-12" / scheduler.LOCK).mkdir(parents=True)
|
||||
code, _, err = self.run_main(["ABC-12"], FakeEffects(on_terminal=False))
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn("cannot lock ", err)
|
||||
self.store.fails = "Jira answered 503"
|
||||
code, _, err = self.run_main(["--chunk", "ABC-12", "ABC-12"], FakeEffects(windows="ABC-12\t0\t@9\n"), MODELS)
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn("Jira answered 503\n", err)
|
||||
|
||||
def test_ends_before_a_cycle_where_the_epic_holds_an_open_issue_again_and_starts_its_chunk(self) -> None:
|
||||
self.issues = [*REVIEWED, issue("ABC-31", "do-epic-claude")]
|
||||
self.description = DESCRIPTION.replace("chunks:** 2", "chunks:** 1")
|
||||
fake = FakeEffects(windows="ABC-12\t0\t@9\n")
|
||||
code, out, err = self.run_main(["--chunk", "ABC-12", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertIn("the epic ABC-12 holds an open issue again, so its finishing waits\n", out)
|
||||
self.assertIn("the epic ABC-12 holds an open issue again, so its finishing chunk ends until none is open\n", out)
|
||||
self.assertIn("the chunk finished; started ABC-31\n", out)
|
||||
self.assertEqual([seam for seam, _ in fake.calls if seam == "stream_claude"], [])
|
||||
|
||||
Reference in New Issue
Block a user