Cut release 0.15.1

This commit is contained in:
Lilleman
2026-11-24 10:17:59 +01:00
parent 0c2f2a5fd1
commit dcd55df69a
7 changed files with 79 additions and 18 deletions
+12
View File
@@ -154,6 +154,18 @@ def project_of(key: str) -> str:
return key.rpartition("-")[0]
def edit_issue(site: str, key: str, body: dict[str, typing.Any], authorization: str, http: Http) -> None | Failure:
"""Sends body, an edit of the issue named key, and returns None, or the Failure of the request that failed. An edit that holds fields or update goes in one request, with its properties. Jira refuses an edit that holds neither, so such an edit sets each property through the property's own endpoint, one request each, and stops at the first that fails."""
if "fields" in body or "update" in body:
answer = http("PUT", f"{site}/rest/api/3/issue/{key}", authorization, body)
return answer if isinstance(answer, Failure) else None
for entry in body.get("properties", []):
answer = http("PUT", f"{site}/rest/api/3/issue/{key}/properties/{entry['key']}", authorization, entry["value"])
if isinstance(answer, Failure):
return answer
return None
def rank_refusal(site: str, key: str, before: str, authorization: str, http: Http) -> str | None:
"""Ranks the issue named key just before the issue named before; why Jira refused, or None where it didn't. Jira answers a rank it made with no body, and one it refused with an error, or with an entry per issue that holds the errors."""
answer = http("PUT", f"{site}/rest/agile/1.0/issue/rank", authorization, {"issues": [key], "rankBeforeIssue": before})
+40
View File
@@ -107,5 +107,45 @@ class TheRefusalOfAnIssueType(unittest.TestCase):
self.assertEqual(self.refusal("Bug", wrong), "Jira answered ABC's issue types in a shape its REST API version 3 doesn't document")
class AnIssueEdit(unittest.TestCase):
def setUp(self) -> None:
self.calls: list[tuple[str, str, object]] = []
self.answer: object = None
def http(self, method: str, url: str, authorization: str, body: object) -> object:
self.calls.append((method, url, body))
return self.answer
def edit(self, body: dict[str, object]) -> None | Failure:
return jira.edit_issue("https://acme.atlassian.net", "ABC-1", body, "Basic x", self.http)
def test_sends_fields_update_and_properties_in_one_request(self):
body = {"fields": {"summary": "Count."}, "update": {"labels": [{"add": "security"}]}, "properties": [{"key": "plan", "value": {"L": 2}}]}
self.assertIsNone(self.edit(body))
self.assertEqual(self.calls, [("PUT", "https://acme.atlassian.net/rest/api/3/issue/ABC-1", body)])
def test_sets_each_property_of_an_edit_without_fields_or_update_through_the_property_endpoint(self):
# Jira's edit refuses such a body: "one of 'fields' or 'update' required".
self.assertIsNone(self.edit({"properties": [{"key": "plan", "value": {"L": 2}}, {"key": "seen", "value": True}]}))
self.assertEqual(self.calls, [
("PUT", "https://acme.atlassian.net/rest/api/3/issue/ABC-1/properties/plan", {"L": 2}),
("PUT", "https://acme.atlassian.net/rest/api/3/issue/ABC-1/properties/seen", True),
])
def test_an_answer_jira_sends_on_success_counts_as_success(self):
self.answer = {"id": "10001"}
self.assertIsNone(self.edit({"fields": {"summary": "Count."}}))
def test_an_empty_edit_doesnt_send_a_request(self):
self.assertIsNone(self.edit({}))
self.assertEqual(self.calls, [])
def test_a_request_jira_refuses_is_its_failure_and_stops_the_later_properties(self):
self.answer = Failure("Jira answered 503")
self.assertEqual(self.edit({"fields": {"summary": "Count."}}), Failure("Jira answered 503"))
self.assertEqual(self.edit({"properties": [{"key": "plan", "value": {}}, {"key": "seen", "value": True}]}), Failure("Jira answered 503"))
self.assertEqual(len(self.calls), 2)
if __name__ == "__main__":
unittest.main()