Kill the surviving mutants of the repo split and the epic comment
CI / tests (pull_request) Has been cancelled

This commit is contained in:
2026-11-18 18:07:12 +01:00
parent adadb88119
commit aa369713fe
3 changed files with 41 additions and 5 deletions
+3 -2
View File
@@ -24,9 +24,10 @@ class MemoryEpicContract(EpicStoreContract, unittest.TestCase):
class Failing(unittest.TestCase):
def test_every_read_and_filing_fails_with_the_reason_given(self) -> None:
def test_every_read_filing_label_and_comment_fails_with_the_reason_given(self) -> None:
store = MemoryEpic("ABC-12", fails="Jira is down")
self.assertEqual((store.read(), store.file("ABC-12", "Count the runs.", "", ())), (Failure("Jira is down"), Failure("Jira is down")))
down = Failure("Jira is down")
self.assertEqual((store.read(), store.file("ABC-12", "Count the runs.", "", ()), store.add_label("ABC-100", "api"), store.comment("ABC-100", "Hello.")), (down, down, down, down))
if __name__ == "__main__":
+7
View File
@@ -212,6 +212,13 @@ class Jira(Case):
refusing = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, lambda text: Failure("not markdown"))
self.assertEqual(refusing.comment(key, "Hello."), Failure("cannot convert the comment to a Jira comment: not markdown"))
def test_an_issue_jira_cannot_read_is_not_commented_on(self) -> None:
store = self.new_store()
key = store.file("ABC-12", "Count the runs.", "", ())
self.jira.answers[("GET", f"{ISSUES}/{key}?fields=parent")] = Failure("Jira answered 500")
self.assertEqual(store.comment(str(key), "Hello."), Failure(f"cannot read {key} to comment on it: Jira answered 500"))
self.assertNotIn(("POST", f"{ISSUES}/{key}/comment"), self.jira.calls)
def test_an_issue_jira_cannot_read_is_not_labelled(self) -> None:
store = self.new_store()
key = store.file("ABC-12", "Count the runs.", "", ())
+31 -3
View File
@@ -66,6 +66,10 @@ class Split_(unittest.TestCase):
self.assertEqual(done, Failure("the repo split gave no comment for the team on a person's issue"))
self.assertEqual((self.tasks(), self.issue().labels), ([], ("api",)))
def test_a_first_filing_that_fails_says_the_run_filed_no_sub_task(self) -> None:
self.store.fails_files = True
self.assertEqual(self.run_split(says(TWO)), Failure(f"cannot file the sub-task for api under {self.key}: Jira answered 500; this run filed no sub-task; run split again to file the rest"))
def test_a_comment_that_fails_files_nothing(self) -> None:
self.store.comment = lambda key, text: Failure("Jira answered 500") # type: ignore[method-assign]
self.assertEqual(self.run_split(says(TWO), by_person=True), Failure("Jira answered 500"))
@@ -111,22 +115,46 @@ class Split_(unittest.TestCase):
self.assertIn(RULE, prompt)
self.assertIn("## Item ABC-100: Count the runs.", prompt)
self.assertIn("write each part's change in Swedish.", prompt)
self.assertIn("Give no comment.", prompt)
self.assertIn("in Swedish. Give no comment.\n", prompt)
self.assertIn("checked out at: /repos/api, /repos/web. Read them", prompt)
self.assertIn("\nLabels: api\n", prompt)
self.assertTrue(prompt.rstrip().endswith("Why it counts."))
def test_tells_claude_of_an_item_with_no_labels_no_description_and_no_checkouts(self) -> None:
key = self.store.file("ABC-12", "Bare item.", "", ())
assert isinstance(key, str)
bare = next(issue for issue in self.issues() if issue.key == key)
claude = says(TWO)
split(self.store, bare, False, RULE, "Swedish", (), RUNG, claude, "/rules")
prompt = claude.calls[0][2]
self.assertIn("checked out at: none. Read them", prompt)
self.assertTrue(prompt.endswith("\nLabels: none\n\n(no description)\n"))
self.assertNotIn("--add-dir", claude.calls[0][0])
def test_asks_a_persons_issue_for_a_comment(self) -> None:
claude = says(TWO)
self.run_split(claude, by_person=True)
self.assertIn("The item is a person's issue: also give a comment, in Swedish,", claude.calls[0][2])
def test_fails_on_an_answer_without_parts_or_with_a_repo_name_that_is_a_path(self) -> None:
for output in ({}, {"parts": "api"}, {"parts": [{"repo": "../x", "change": "c"}]}, {"parts": [{"repo": "api"}]}, {"parts": [3]}):
for output in ({}, "nope", {"parts": "api"}, {"parts": [{"repo": "../x", "change": "c"}]}, {"parts": [{"repo": "api"}]}, {"parts": [3]}):
with self.subTest(output=output):
self.assertIsInstance(self.run_split(says(output)), Failure)
self.assertEqual(self.tasks(), [])
def test_an_answer_that_fails_is_quoted_up_to_two_hundred_characters(self) -> None:
output = {"parts": "x" * 300}
failed = self.run_split(says(output))
self.assertEqual(failed, Failure(f"the repo split answered {json.dumps(output)[:200]}; expected parts, each with a repo name of letters, digits, dots, hyphens and underscores and a change"))
def test_a_label_that_fails_after_the_sub_tasks_names_them_and_leaves_the_item_unmarked(self) -> None:
self.store.add_label = lambda key, label: Failure("Jira answered 500") if label == SPLIT_LABEL else None # type: ignore[method-assign]
failed = self.run_split(says(TWO))
first, second = (task.key for task in self.tasks())
self.assertEqual(failed, Failure(f"cannot mark {self.key} as split: Jira answered 500; this run filed {first}, {second}; run split again to mark it"))
def test_passes_on_a_failed_or_limited_claude(self) -> None:
self.assertIsInstance(self.run_split(Claude("", 1)), Failure)
self.assertEqual(self.run_split(Claude("", 1)), Failure("the repo split exited 1"))
limited = self.run_split(Claude(json.dumps({"type": "result", "is_error": True, "api_error_status": 429, "result": "You've hit your limit"})))
self.assertIsInstance(limited, Limited)