Fail the comment through a field of the test epic, not a patched method
CI / tests (pull_request) Successful in 3m22s
CI / tests (pull_request) Successful in 3m22s
This commit is contained in:
@@ -19,13 +19,17 @@ TWO = {"parts": [{"repo": "api", "change": "Serve the count."}, {"repo": "web",
|
|||||||
|
|
||||||
|
|
||||||
class Flaky(MemoryEpic):
|
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
|
jammed = False
|
||||||
fails_files = False
|
fails_files = False
|
||||||
|
fails_comments = False
|
||||||
|
|
||||||
def file(self, parent: str, summary: str, detail: str, labels: tuple[str, ...]) -> str | Failure:
|
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)
|
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):
|
class Split_(unittest.TestCase):
|
||||||
def setUp(self) -> None:
|
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"))
|
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:
|
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)
|
failed = self.run_split(says(TWO), by_person=True)
|
||||||
first, second = (task.key for task in self.tasks())
|
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(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",))
|
self.assertEqual(self.issue().labels, ("api",))
|
||||||
del self.store.comment
|
self.store.fails_comments = False
|
||||||
done = self.run_split(says(TWO), by_person=True)
|
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)))
|
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)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user