Answer prose round 1: 1 🔴, 3 🟡 (0 misread); clearer docstrings, test names and item text, and AnIssueEdit above the main guard
CI / tests (pull_request) Has been cancelled
CI / tests (pull_request) Has been cancelled
This commit is contained in:
@@ -155,7 +155,7 @@ def project_of(key: str) -> str:
|
||||
|
||||
|
||||
def edit_issue(site: str, key: str, body: dict[str, typing.Any], authorization: str, http: Http) -> None | Failure:
|
||||
"""Sends an edit of the issue named key: its fields, its updates and its issue properties in one request, or the Failure Jira answered. Jira refuses an edit that holds neither fields nor update, so such an edit sets each property through the property's own endpoint, one request each, and stops at the first that fails."""
|
||||
"""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
|
||||
|
||||
@@ -107,10 +107,6 @@ 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")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class AnIssueEdit(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.calls: list[tuple[str, str, object]] = []
|
||||
@@ -136,16 +132,20 @@ class AnIssueEdit(unittest.TestCase):
|
||||
("PUT", "https://acme.atlassian.net/rest/api/3/issue/ABC-1/properties/seen", True),
|
||||
])
|
||||
|
||||
def test_an_answer_jira_sends_on_success_is_no_failure(self):
|
||||
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_edit_that_sets_nothing_sends_no_request(self):
|
||||
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_sets_no_later_property(self):
|
||||
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()
|
||||
|
||||
@@ -198,7 +198,7 @@ class JiraPlan:
|
||||
return isinstance(texts, list) and texts[0].strip() == detail.strip()
|
||||
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure:
|
||||
"""Sets the fields, the detail and the scores in one request, so Jira takes all of those or none, or sets the scores alone as `edit_issue` says, then changes the issue's links one request at a time, and then posts comment on the issue. `revision_of` says what an edit may set.
|
||||
"""Sets the fields, the detail and the scores in one request, so Jira takes all of those or none. Where the edit changes only the scores, `edit_issue` sets them through their property's endpoint. Then it changes the issue's links one request at a time, and then posts comment on the issue. `revision_of` says what an edit may set.
|
||||
|
||||
A link change or a comment Jira refuses leaves the edit made, so the write counts as landed, and a note says what to do by hand."""
|
||||
authorization = basic_auth(self.env_file)
|
||||
|
||||
@@ -111,9 +111,9 @@
|
||||
|
||||
### 533. Set an issue's scores in Jira through its issue-property endpoint, so do-epic and `todo-item edit` save them where Jira refuses an edit that holds only properties.
|
||||
|
||||
Jira Cloud's edit request, `PUT /rest/api/3/issue/{key}`, refuses a body that holds `properties` without `fields` or `update`: it answers 400 "one of 'fields' or 'update' required". do-epic's scoring sends exactly that body, after it has posted the comment that tells the team the scores. So on a team's epic every scored issue got the comment but no scores, and each later run would score and comment on it again. `todo-item edit` sends the same body where it changes only the scores of an issue, as it does on an issue a person filed. The test fakes accepted the body, so no test saw it.
|
||||
Jira Cloud's edit request, `PUT /rest/api/3/issue/{key}`, refuses a body that holds `properties` without `fields` or `update`: it answers 400 "one of 'fields' or 'update' required". do-epic's scoring sends exactly that body, after it has posted the comment that tells the team the scores. So on a team's epic every scored issue got the comment but no scores, and each later run would score and comment on it again. `todo-item edit` sends the same body where it changes only an issue's scores, which is all it may change on an issue a person filed. The test fakes accepted that body, so no test caught the refusal.
|
||||
|
||||
Fix: one function in `bin/atlassian/jira.py` sends an issue edit. Where the edit sets only issue properties, it sets each through `PUT /rest/api/3/issue/{key}/properties/{propertyKey}`, whose body is the property's value. Both callers use it, and both fakes refuse an edit that holds neither `fields` nor `update`, as Jira does.
|
||||
Fix: one function in `bin/atlassian/jira.py` sends an issue edit. Where the edit sets only issue properties, it sets each through `PUT /rest/api/3/issue/{key}/properties/{propertyKey}`, whose body is the property's value. Both callers use it, and the fakes in both callers' tests refuse an edit that holds neither `fields` nor `update`, as Jira does.
|
||||
|
||||
Touches:
|
||||
- `bin/atlassian/jira.py`: `edited`
|
||||
|
||||
Reference in New Issue
Block a user