Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s
CI / tests (pull_request) Successful in 3m43s
This commit is contained in:
@@ -12,7 +12,7 @@ from atlassian.client import basic_auth, Http, jira_json, ToAdf, ToMarkdown
|
||||
from plan.todo_table import BLOCKED_BY, Item, item_fields, ItemFields, MOVES, SHAPE
|
||||
from plan_store.markdown_edits import bold_cell, plain, unfit_text
|
||||
from plan_store.plans import cells, no_item, Plan, Written
|
||||
from atlassian.jira import entry_of, finishing_transition, ISSUE_KEY, Link, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, unshaped
|
||||
from atlassian.jira import entry_of, finishing_transition, ISSUE_KEY, Link, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, unshaped
|
||||
from project_config.settings import Epic, Finish, JIRA_FINISH_STATUS, JIRA_FINISH_TRANSITION
|
||||
from failure import Failure
|
||||
from plan.release import parsed, Release, tagged
|
||||
@@ -71,6 +71,8 @@ class JiraPlan:
|
||||
to_adf: ToAdf = markdown_to_adf
|
||||
# How a finished item moves; None where the config doesn't say, and then `finish` is a Failure.
|
||||
finish_by: Finish | None = None
|
||||
# The pages a search may take before the read fails.
|
||||
max_pages: int = MAX_PAGES
|
||||
# How add scores an item: by the config's formula and bar, with the goal weights the project's records give.
|
||||
scoring: ReadsScoring = dataclasses.field(kw_only=True)
|
||||
|
||||
@@ -86,7 +88,7 @@ class JiraPlan:
|
||||
authorization = basic_auth(self.env_file)
|
||||
if isinstance(authorization, Failure):
|
||||
return authorization
|
||||
answered = children(self.epic, authorization, self.http)
|
||||
answered = children(self.epic, authorization, self.http, self.max_pages)
|
||||
if isinstance(answered, Failure):
|
||||
return answered
|
||||
issues = [issue_of(raw) for raw in answered]
|
||||
@@ -115,7 +117,7 @@ class JiraPlan:
|
||||
version = self.fix_version(filing.release, authorization)
|
||||
if isinstance(version, Failure):
|
||||
return version
|
||||
answered = children(self.epic, authorization, self.http)
|
||||
answered = children(self.epic, authorization, self.http, self.max_pages)
|
||||
if isinstance(answered, Failure):
|
||||
return answered
|
||||
if missing := missing_blocker(filing.blockers, keys_of(answered), self.label):
|
||||
@@ -170,7 +172,7 @@ class JiraPlan:
|
||||
|
||||
def child(self, id_: int, authorization: str) -> dict[str, typing.Any] | Failure:
|
||||
"""Item id_'s issue, as the epic's open children answer it; a Failure where none of them is item id_."""
|
||||
answered = children(self.epic, authorization, self.http)
|
||||
answered = children(self.epic, authorization, self.http, self.max_pages)
|
||||
return answered if isinstance(answered, Failure) else self.child_in(answered, id_)
|
||||
|
||||
def child_in(self, answered: list[object], id_: int) -> dict[str, typing.Any] | Failure:
|
||||
@@ -200,7 +202,7 @@ class JiraPlan:
|
||||
authorization = basic_auth(self.env_file)
|
||||
if isinstance(authorization, Failure):
|
||||
return authorization
|
||||
answered = children(self.epic, authorization, self.http)
|
||||
answered = children(self.epic, authorization, self.http, self.max_pages)
|
||||
if isinstance(answered, Failure):
|
||||
return answered
|
||||
raw = self.child_in(answered, id_)
|
||||
@@ -376,13 +378,13 @@ def revision_of(issue: Issue, named: dict[str, str], detail: str | None, comment
|
||||
return Revision(body, release, tuple(dict.fromkeys(f"{project_of(issue.key)}-{blocker}" for blocker in checked.blocked_by)) if BLOCKED_BY in named else None)
|
||||
|
||||
|
||||
def children(epic: Epic, authorization: str, http: Http) -> list[object] | Failure:
|
||||
def children(epic: Epic, authorization: str, http: Http, max_pages: int) -> list[object] | Failure:
|
||||
"""The epic's open child issues in backlog order, which the team ranks, apart from where add ranks an issue it files. An issue in a done status is a finished item, so it is no longer in the plan."""
|
||||
# The search answers no issues for an epic the account cannot see, as for one whose children are all done; asking for the epic itself tells them apart.
|
||||
seen = http("GET", f"{epic.site}/rest/api/3/issue/{epic.key}?fields=summary", authorization, None)
|
||||
if isinstance(seen, Failure):
|
||||
return Failure(f"cannot read the epic {epic.key}: {seen.reason}")
|
||||
return searched(epic.site, f"{epic.key}'s children", f'parent = "{epic.key}" AND statusCategory != Done ORDER BY Rank ASC', {"fields": ["summary", "description", "fixVersions", "issuelinks"], "properties": [PROPERTY]}, authorization, http)
|
||||
return searched(epic.site, f"{epic.key}'s children", f'parent = "{epic.key}" AND statusCategory != Done ORDER BY Rank ASC', {"fields": ["summary", "description", "fixVersions", "issuelinks"], "properties": [PROPERTY]}, authorization, http, max_pages)
|
||||
|
||||
|
||||
def issue_of(raw: object) -> Issue | Failure:
|
||||
|
||||
@@ -4,7 +4,6 @@ import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import unittest.mock
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
@@ -171,8 +170,7 @@ class JiraPlan(unittest.TestCase):
|
||||
|
||||
def test_a_search_that_never_names_a_last_page_fails_the_read(self):
|
||||
self.pages = [{"issues": [], "nextPageToken": "more"}] * 2
|
||||
with unittest.mock.patch("atlassian.jira.MAX_PAGES", 2):
|
||||
self.assertEqual(self.store().read(), Failure("the search for ABC-12's children did not end within 2 pages"))
|
||||
self.assertEqual(dataclasses.replace(self.store(), max_pages=2).read(), Failure("the search for ABC-12's children did not end within 2 pages"))
|
||||
|
||||
def test_an_issue_in_another_shape_fails_the_read_naming_it(self):
|
||||
good = issue("ABC-1")
|
||||
|
||||
Reference in New Issue
Block a user