Answer stability round 1: 1 🔴, 2 🟡 (0 misread); post a person's comment once the sub-tasks exist, count filed sub-tasks towards the split, and refuse a blank change
CI / tests (pull_request) Successful in 3m20s
CI / tests (pull_request) Successful in 3m20s
This commit is contained in:
+25
-11
@@ -56,7 +56,7 @@ class Split_(unittest.TestCase):
|
||||
self.assertEqual(self.issue().labels, ("api", SPLIT_LABEL))
|
||||
self.assertEqual(self.store.comments, {})
|
||||
|
||||
def test_comments_on_a_persons_issue_for_the_team_before_filing(self) -> None:
|
||||
def test_comments_on_a_persons_issue_for_the_team_once_its_sub_tasks_are_filed(self) -> None:
|
||||
self.run_split(says(TWO), by_person=True)
|
||||
self.assertEqual(self.store.comments, {self.key: ["Delat per repo: api och web."]})
|
||||
self.assertEqual(len(self.tasks()), 2)
|
||||
@@ -70,10 +70,25 @@ class Split_(unittest.TestCase):
|
||||
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:
|
||||
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.assertEqual(self.run_split(says(TWO), by_person=True), Failure("Jira answered 500"))
|
||||
self.assertEqual(self.tasks(), [])
|
||||
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
|
||||
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)))
|
||||
|
||||
def test_a_person_who_filed_a_sub_task_for_one_repo_still_gets_the_comment_and_the_rest_are_filed(self) -> None:
|
||||
self.store.file(self.key, "Own task.", "", ("repo:api",))
|
||||
done = self.run_split(says(TWO), by_person=True)
|
||||
self.assertEqual((done.repos, [task.labels for task in self.tasks()], self.store.comments[self.key]), (("api", "web"), [("repo:api",), ("repo:web",)], ["Delat per repo: api och web."]))
|
||||
|
||||
def test_a_sub_task_already_filed_counts_towards_the_split_whatever_the_new_prediction_says(self) -> None:
|
||||
self.store.file(self.key, "Own task.", "", ("repo:api",))
|
||||
done = self.run_split(says({"parts": [{"repo": "web", "change": "Show the count."}]}))
|
||||
self.assertEqual((done.repos, [task.labels for task in self.tasks()]), (("api", "web"), [("repo:api",), ("repo:web",)]))
|
||||
|
||||
def test_splits_nothing_where_the_item_changes_one_repo_or_none(self) -> None:
|
||||
for parts in ([], [{"repo": "api", "change": "Serve the count."}], [{"repo": "api", "change": "a"}, {"repo": "api", "change": "b"}]):
|
||||
@@ -87,12 +102,11 @@ class Split_(unittest.TestCase):
|
||||
self.assertEqual(self.run_split(claude), Split((), ()))
|
||||
self.assertEqual((claude.calls, self.tasks()), ([], []))
|
||||
|
||||
def test_a_first_filing_that_fails_after_the_comment_posts_the_comment_again_on_the_next_run(self) -> None:
|
||||
def test_a_filing_that_keeps_failing_posts_no_comment(self) -> None:
|
||||
self.store.fails_files = True
|
||||
self.assertIsInstance(self.run_split(says(TWO), by_person=True), Failure)
|
||||
self.store.fails_files = False
|
||||
self.run_split(says(TWO), by_person=True)
|
||||
self.assertEqual(self.store.comments[self.key], ["Delat per repo: api och web."] * 2)
|
||||
for _ in range(2):
|
||||
self.assertIsInstance(self.run_split(says(TWO), by_person=True), Failure)
|
||||
self.assertEqual(self.store.comments, {})
|
||||
|
||||
def test_a_failed_filing_names_what_was_filed_and_a_second_run_files_only_the_rest(self) -> None:
|
||||
self.store.jammed = True
|
||||
@@ -144,7 +158,7 @@ class Split_(unittest.TestCase):
|
||||
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 ({}, "nope", {"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]}, {"parts": [{"repo": "api", "change": " "}]}):
|
||||
with self.subTest(output=output):
|
||||
self.assertIsInstance(self.run_split(says(output)), Failure)
|
||||
self.assertEqual(self.tasks(), [])
|
||||
@@ -152,7 +166,7 @@ class Split_(unittest.TestCase):
|
||||
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"))
|
||||
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 that holds text"))
|
||||
|
||||
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]
|
||||
|
||||
Reference in New Issue
Block a user