diff --git a/bin/do_epic/test_split.py b/bin/do_epic/test_split.py index edc64e38..1cc9be84 100644 --- a/bin/do_epic/test_split.py +++ b/bin/do_epic/test_split.py @@ -19,13 +19,17 @@ TWO = {"parts": [{"repo": "api", "change": "Serve the count."}, {"repo": "web", class Flaky(MemoryEpic): - """An epic that, while jammed is set, files no sub-task after the first under an issue.""" + """An epic that fails on demand: while jammed is set it files no sub-task after the first under an issue, and fails_files and fails_comments fail every filing and comment.""" jammed = False fails_files = False + fails_comments = False def file(self, parent: str, summary: str, detail: str, labels: tuple[str, ...]) -> str | Failure: return Failure("Jira answered 500") if self.fails_files or self.jammed and any(issue.parent == parent for issue in self.issues) else super().file(parent, summary, detail, labels) + def comment(self, key: str, text: str) -> None | Failure: + return Failure("Jira answered 500") if self.fails_comments else super().comment(key, text) + class Split_(unittest.TestCase): def setUp(self) -> None: @@ -71,12 +75,12 @@ class Split_(unittest.TestCase): 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_leaves_the_item_unmarked_and_the_next_run_files_nothing_again(self) -> None: - self.store.comment = lambda key, text: Failure("Jira answered 500") # type: ignore[method-assign] + self.store.fails_comments = True failed = self.run_split(says(TWO), by_person=True) first, second = (task.key for task in self.tasks()) self.assertEqual(failed, Failure(f"cannot comment on {self.key}: Jira answered 500; this run filed {first}, {second}; run split again to post it")) self.assertEqual(self.issue().labels, ("api",)) - del self.store.comment + self.store.fails_comments = False done = self.run_split(says(TWO), by_person=True) self.assertEqual((done, len(self.tasks()), self.store.comments[self.key], self.issue().labels), (Split(("api", "web"), ()), 2, ["Delat per repo: api och web."], ("api", SPLIT_LABEL)))