Test the start's failure messages and shapes that mutants survived
CI / tests (pull_request) Successful in 3m42s

This commit is contained in:
Lilleman
2026-11-20 18:03:55 +01:00
parent f40f7eb95c
commit 6bd146395c
4 changed files with 23 additions and 3 deletions
+1 -1
View File
@@ -91,6 +91,6 @@ def sprint_refusal(site: str, key: str, board: int, authorization: str, http: Ht
if not isinstance(values, list) or len(sprints) != len(values):
return Failure(f"Jira answered board {board}'s sprints in a shape other than the one it documents")
if len(sprints) != 1:
return Failure(f"board {board}, which `{SPRINT_BOARD}` names, has {len(sprints) or 'no'} active sprint{'s' * (len(sprints) > 1)}, so {key} joins none")
return Failure(f"board {board}, which `{SPRINT_BOARD}` names, has {f"{len(sprints)} active sprints" if sprints else "no active sprint"}, so {key} joins none")
added = http("POST", f"{site}/rest/agile/1.0/sprint/{sprints[0]}/issue", authorization, {"issues": [key]})
return Failure(f"cannot add {key} to the active sprint of board {board}: {added.reason}") if isinstance(added, Failure) else None
+4
View File
@@ -47,6 +47,10 @@ class Failing(unittest.TestCase):
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."), store.rank("ABC-100", "ABC-101")), (down,) * 5)
def test_a_start_fails_with_the_reason_given_and_one_outside_the_epic_says_so(self) -> None:
self.assertEqual(MemoryEpic("ABC-12", fails="Jira is down").start_issue("ABC-100"), Failure("Jira is down"))
self.assertEqual(MemoryEpic("ABC-12").start_issue("ABC-100"), Failure("ABC-100 is not one of the child issues of the epic ABC-12, so it cannot be started"))
class Blocking(unittest.TestCase):
def test_refuses_a_blocker_that_is_an_issue_of_another_epic(self) -> None:
+16
View File
@@ -348,14 +348,18 @@ class Jira(Case):
({("GET", f"{ISSUES}/{key}?fields=assignee,status"): {"fields": {"assignee": None}}}, f"{key} is not in the shape Jira Cloud's REST API version 3 documents: KeyError('status')"),
({("GET", MYSELF): Failure("Jira answered 503")}, f"cannot read which account do-epic works as, to assign {key}: Jira answered 503"),
({("GET", MYSELF): {"displayName": "Do Epic"}}, f"cannot assign {key}: Jira named no account ID for the account do-epic works as"),
({("GET", MYSELF): ["Do Epic"]}, f"cannot assign {key}: Jira named no account ID for the account do-epic works as"),
({("PUT", assignee): Failure("Jira answered 403")}, f"cannot assign {key}: Jira answered 403"),
({("GET", transitions): Failure("Jira answered 503")}, f"cannot read {key}'s transitions: Jira answered 503"),
({("GET", transitions): {"transitions": [{"id": "21"}]}}, f"Jira answered {key}'s transitions in a shape other than the one it documents"),
({("GET", transitions): {"transitions": [{"id": "31", "name": "Mark as done", "to": DONE}]}}, f"{key} has no transition 'Start' from its status 'To Do', only 'Mark as done' to 'Done': name in `jira-start-transition` one that its statuses before work starts have"),
({("GET", transitions): {"transitions": [{"id": "31", "name": "Mark as done", "to": DONE}, {"id": "41", "name": "Wait", "to": TO_DO}]}}, f"{key} has no transition 'Start' from its status 'To Do', only 'Mark as done' to 'Done' and 'Wait' to 'To Do': name in `jira-start-transition` one that its statuses before work starts have"),
({("GET", transitions): {"transitions": []}}, f"{key} has no transition 'Start' from its status 'To Do', nor any other the account may make"),
({("POST", transitions): Failure("Jira answered 400")}, f"cannot move {key} by 'Start': Jira answered 400"),
({("GET", ACTIVE_SPRINTS): Failure("Jira answered 400")}, f"cannot read the active sprint of board 6, which `jira-sprint-board` names: Jira answered 400"),
({("GET", ACTIVE_SPRINTS): {"values": [{"name": "Sprint 9"}]}}, "Jira answered board 6's sprints in a shape other than the one it documents"),
({("GET", ACTIVE_SPRINTS): [{"id": 77}]}, "Jira answered board 6's sprints in a shape other than the one it documents"),
({("GET", ACTIVE_SPRINTS): {"values": "Sprint 9"}}, "Jira answered board 6's sprints in a shape other than the one it documents"),
({("GET", ACTIVE_SPRINTS): {"values": []}}, f"board 6, which `jira-sprint-board` names, has no active sprint, so {key} joins none"),
({("GET", ACTIVE_SPRINTS): {"values": [{"id": 77}, {"id": 78}]}}, f"board 6, which `jira-sprint-board` names, has 2 active sprints, so {key} joins none"),
({("POST", SPRINT_ISSUES): Failure("Jira answered 403")}, f"cannot add {key} to the active sprint of board 6: Jira answered 403"),
@@ -369,6 +373,18 @@ class Jira(Case):
store.start_issue(key)
self.assertEqual((self.jira.issues[0]["fields"]["status"], self.jira.sprinted), (IN_PROGRESS, [[key]])) # type: ignore[index]
def test_a_start_whose_issue_or_parent_jira_cannot_read_or_that_the_epic_does_not_hold_says_which(self) -> None:
store = self.starting()
child = store.file("ABC-12", "Count the runs.", "", ())
task = store.file(child, "Count them in the api.", "", ())
self.jira.issues.append({"key": "ABC-61", "fields": {"summary": "Other.", "description": None, "labels": [], "assignee": None, "status": TO_DO, "parent": None, "issuelinks": []}})
self.assertEqual(store.start_issue("ABC-61"), Failure("ABC-61 is not one of the child issues of the epic ABC-12, so it cannot be started"))
self.jira.answers[("GET", f"{ISSUES}/{task}?fields=parent,status")] = Failure("Jira answered 503")
self.assertEqual(store.start_issue(task), Failure(f"cannot read {task} to start it: Jira answered 503"))
del self.jira.answers[("GET", f"{ISSUES}/{task}?fields=parent,status")]
self.jira.answers[("GET", f"{ISSUES}/{child}?fields=parent,status")] = Failure("Jira answered 503")
self.assertEqual(store.start_issue(task), Failure(f"cannot read {child} to start its sub-task: Jira answered 503"))
def test_finishes_an_issue_by_the_transition_the_settings_name(self) -> None:
store = self.new_store()
key = store.file("ABC-12", "Count the runs.", "", ())
+2 -2
View File
@@ -119,10 +119,10 @@ class ConfigTest(unittest.TestCase):
found = load(self.home)
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.start, Start(None, None))
self.write(SETTINGS + 'jira-start-transition = "In Progress"\njira-sprint-board = 6\n')
self.write(SETTINGS + 'jira-start-transition = "In Progress"\njira-sprint-board = 1\n')
found = load(self.home)
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.start, Start("In Progress", 6))
self.assertEqual(found.start, Start("In Progress", 1))
for board, read in (('"6"', "'6'"), ("0", "0"), ("true", "True"), ("6.0", "6.0")):
with self.subTest(board=board):
self.write(SETTINGS + f'jira-start-transition = " "\njira-sprint-board = {board}\n')