Kill the surviving mutants of the scoring and ranking

This commit is contained in:
2026-11-16 02:50:37 +01:00
parent 9d9c5a3352
commit 727ed70ecb
5 changed files with 56 additions and 5 deletions
+23 -3
View File
@@ -394,6 +394,12 @@ class Filing(unittest.TestCase):
self.assertEqual(self.add(FIELDS | {"Moves": "2 by 1", "S": "3"}), Failure("the item to file scores 0.1, under the bar 1; don't file it, or mark it with a reason the bar doesn't apply"))
self.assertEqual(self.calls, [])
def test_the_bar_holds_the_score_rounded_to_one_decimal(self):
for formula, bar, filed_ in (("0.96", 1, True), ("0.6", 0.7, False)):
with self.subTest(formula=formula, bar=bar):
self.scoring = Stated(formula=formula, bar=bar)
self.assertEqual(self.add() == Written(40), filed_)
def test_an_exempt_item_under_the_bar_files(self):
self.assertEqual(self.add(FIELDS | {"Moves": "", "Exempt": "owner"}), Written(40))
@@ -410,6 +416,11 @@ class Filing(unittest.TestCase):
self.assertEqual(self.add(), Failure("cannot score the item to file: the formula 'V +' does not parse"))
self.assertEqual(self.calls, [])
def test_a_formula_that_gives_the_item_no_finite_score_fails_before_any_request(self):
self.scoring = Stated(formula="1 ** (1 / (S - S))")
self.assertEqual(self.add(), Failure("the formula gives the item to file no finite score"))
self.assertEqual(self.calls, [])
def test_a_config_without_a_formula_fails(self):
self.scoring = None
self.assertEqual(self.add(), Failure("the config states no formula and bar to score the item by: set `jira-score-formula` and `jira-score-bar`, as `project-config --help` shows"))
@@ -436,6 +447,7 @@ class Filing(unittest.TestCase):
refusals = (
(Failure("PUT /rest/agile/1.0/issue/rank answered 403: Forbidden"), "PUT /rest/agile/1.0/issue/rank answered 403: Forbidden"),
({"entries": [{"issueKey": "ABC-40", "status": 400, "errors": ["Rank is not configured"]}]}, "Rank is not configured"),
({"entries": [{"status": 200}, {"status": 400}, {"status": 404, "errors": ["gone", "locked"]}]}, "Jira answered 400; gone; locked"),
)
for answer, reason in refusals:
with self.subTest(answer=answer):
@@ -443,9 +455,17 @@ class Filing(unittest.TestCase):
self.assertEqual(self.add(), Written(40, (f"filed ABC-40, but cannot rank it before ABC-34: {reason}; rank it in Jira",)))
def test_an_issue_the_loop_filed_that_does_not_score_leaves_the_item_filed_unranked_with_a_note(self):
self.open = [filed("ABC-34", moves="3 by 1", s=2)]
self.assertEqual(self.add(), Written(40, ("filed ABC-40, but cannot rank it: ABC-34 cites goal 3, which the goals file's ## Goals does not number; rank it in Jira",)))
self.assertEqual(self.sent(RANK), [])
unscored = {name: value for name, value in PROPERTY.items() if name != "S"}
for open_, reason in (
(filed("ABC-34", moves="3 by 1", s=2), "ABC-34 cites goal 3, which the goals file's ## Goals does not number"),
(issue("ABC-34", scores=unscored), "ABC-34 holds no S"),
(issue("ABC-34", scores=PROPERTY | {"L": 11}), "item ABC-34's L '11' is not a whole number from 1 to 4"),
):
with self.subTest(reason=reason):
self.calls.clear()
self.open = [open_]
self.assertEqual(self.add(), Written(40, (f"filed ABC-40, but cannot rank it: {reason}; rank it in Jira",)))
self.assertEqual(self.sent(RANK), [])
TRANSITIONS = "https://acme.atlassian.net/rest/api/3/issue/ABC-34/transitions"