From e8255be53412e58681cb2f5206136bc3cdf3f540 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 18:32:38 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20score=20the?= =?UTF-8?q?=20person's=20issue=20in=20the=20contract=20test,=20and=20hold?= =?UTF-8?q?=20scores,=20moves=20and=20exempt=20apart=20from=20blockers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/do_epic/backend/contract.py | 16 ++++++++-------- bin/do_epic/backend/jira.py | 4 ++-- bin/do_epic/backend/protocol.py | 14 +++++++++----- bin/do_epic/backend/test_fake.py | 6 ++++-- bin/do_epic/backend/test_jira.py | 2 +- bin/plan_store/jira_epic.py | 2 +- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/bin/do_epic/backend/contract.py b/bin/do_epic/backend/contract.py index 11d38cef..c865bb0f 100644 --- a/bin/do_epic/backend/contract.py +++ b/bin/do_epic/backend/contract.py @@ -1,10 +1,9 @@ -"""What every backend of an epic's plan must hold, as tests. A backend's test case inherits EpicStoreContract and unittest.TestCase, and builds an epic with no issues in new_store. Its assign, close, person_files, score and block change the tracker as a person, or the plan store, would.""" +"""What every backend of an epic's plan must hold, as tests. A backend's test case inherits EpicStoreContract and unittest.TestCase, and builds an epic with no issues in new_store. Its assign, close, person_files, score and block change the tracker as a person or the plan store would.""" import re import typing from do_epic.backend.protocol import EpicIssue, EpicStore from failure import Failure -from plan.todo_table import ItemFields class EpicStoreContract: @@ -27,8 +26,8 @@ class EpicStoreContract: """Files a child issue of the epic as a person does in the tracker, not through the store, and answers its key.""" raise NotImplementedError - def score(self, store: EpicStore, key: str, scores: dict[str, str]) -> None: - """Sets the scores of the issue named key, as `plan_store` writes them: each column's name with its value as text, such as {"L": "2", "Moves": "1 by 5"}.""" + def score(self, store: EpicStore, key: str, scores: dict[str, object]) -> None: + """Sets the scores of the issue named key as `plan_store` writes them: each column's name with its value, a whole number for a score and text for Moves and Exempt, such as {"L": 2, "Moves": "1 by 5"}.""" raise NotImplementedError def block(self, store: EpicStore, key: str, blocker: str) -> None: @@ -125,15 +124,14 @@ class EpicStoreContract: store = self.new_store() key = self.filed(store, store.epic_key, "Count the runs.") [issue] = self.issues(store) - self.assertEqual((issue.key, issue.scores, issue.blockers), (key, ItemFields(), ())) + self.assertEqual((issue.key, issue.scores, issue.moves, issue.exempt, issue.blockers), (key, {}, (), "", ())) def test_reads_the_scores_a_person_or_the_plan_store_set(self) -> None: store = self.new_store() key = self.filed(store, store.epic_key, "Count the runs.") - self.score(store, key, {"L": "2", "E": "3", "I": "4", "S": "3", "Moves": "1 by 5", "Exempt": "security"}) + self.score(store, key, {"L": 2, "E": 3, "I": 4, "S": 3, "Moves": "1 by 5", "Exempt": "security"}) [issue] = self.issues(store) - self.assertEqual((issue.scores.scores, issue.scores.moves, issue.scores.exempt), ({"L": 2, "E": 3, "I": 4, "S": 3}, (("1", 5),), "security")) - self.assertEqual((issue.scores.release, issue.scores.blocked_by), (None, ())) + self.assertEqual((issue.scores, issue.moves, issue.exempt), ({"L": 2, "E": 3, "I": 4, "S": 3}, (("1", 5),), "security")) def test_reads_each_blocker_of_an_issue_and_none_for_a_blocker_of_another(self) -> None: store = self.new_store() @@ -147,6 +145,8 @@ class EpicStoreContract: store = self.new_store() ours = self.filed(store, store.epic_key, "Count the runs.") theirs = self.person_files(store, "A person's issue.") + # The plan store scores an issue a person filed without making it the loop's. + self.score(store, theirs, {"L": 2, "E": 3, "I": 4, "S": 3, "Moves": "1 by 5"}) task = self.filed(store, ours, "Count them in the api.") read = {issue.key: issue for issue in self.issues(store)} self.assertEqual([read[key].by_loop for key in (ours, theirs, task)], [True, False, True]) diff --git a/bin/do_epic/backend/jira.py b/bin/do_epic/backend/jira.py index 730f885f..d31f570b 100644 --- a/bin/do_epic/backend/jira.py +++ b/bin/do_epic/backend/jira.py @@ -60,7 +60,7 @@ class JiraEpic: if refused := unfit(summary, labels) or self.not_a_parent(parent, authorization): return refused fields: dict[str, typing.Any] = {"project": {"key": project_of(parent)}, "parent": {"key": parent}, "summary": summary, "labels": list(labels)} - # The mark that tells the loop's issues from a person's, as plan_store marks the items it files. + # Marks the issue as the loop's, as plan_store marks the items it files. properties = [{"key": PROPERTY, "value": {FILED_BY[0]: FILED_BY[1]}}] kind = {"name": ISSUE_TYPE} if parent == self.epic_key else self.sub_task_type(project_of(parent), authorization) if isinstance(kind, Failure): @@ -173,4 +173,4 @@ def found_of(raw: object) -> Found | Failure: read = scores(key, held) if isinstance(read, Failure): return read - return Found(EpicIssue(key, summary.strip(), "", tuple(sorted(labels)), name, state, done, parent, read, blockers, held.get(FILED_BY[0]) == FILED_BY[1]), description) + return Found(EpicIssue(key, summary.strip(), "", tuple(sorted(labels)), name, state, done, parent, read.scores, read.moves, read.exempt, blockers, held.get(FILED_BY[0]) == FILED_BY[1]), description) diff --git a/bin/do_epic/backend/protocol.py b/bin/do_epic/backend/protocol.py index 78b30cb6..3da13e8e 100644 --- a/bin/do_epic/backend/protocol.py +++ b/bin/do_epic/backend/protocol.py @@ -5,8 +5,8 @@ import dataclasses import re import typing +from plan.todo_table import Exempt, Moves from failure import Failure -from plan.todo_table import ItemFields # What a tracker accepts as a label: Jira refuses a label holding white space. LABEL = re.compile(r"\S+") @@ -29,11 +29,15 @@ class EpicIssue: done: bool # The epic's key for a child issue, the child's key for a sub-task. parent: str - # The scores, Moves and Exempt a plan-item issue property holds, as `plan_store` reads them; its release and blocked_by stay unset, since an epic's items have no release and `blockers` holds theirs. Empty where the issue holds none, as a person's issue does. - scores: ItemFields = dataclasses.field(default_factory=ItemFields) - # The key of each issue this one is blocked by, in the tracker's order. + # The score of each column the issue has one for, such as {"L": 2}, as `plan_store` reads them from the issue's `plan-item` property. Empty where the issue has no scores. + scores: dict[str, int] = dataclasses.field(default_factory=dict) + # The goals the issue moves, and how far (the plan's Moves cell); empty where it names none. + moves: Moves = () + # Why the issue is exempt from the plan's score bar, as the plan's Exempt cell names it; empty where it isn't. + exempt: Exempt = "" + # The key of each issue that blocks this one, in the tracker's order. blockers: tuple[str, ...] = () - # Whether the loop filed the issue, through EpicStore.file, rather than a person. + # True where the loop filed the issue through EpicStore.file; False for an issue a person filed. by_loop: bool = False diff --git a/bin/do_epic/backend/test_fake.py b/bin/do_epic/backend/test_fake.py index 40632ba8..24db7161 100644 --- a/bin/do_epic/backend/test_fake.py +++ b/bin/do_epic/backend/test_fake.py @@ -25,8 +25,10 @@ class MemoryEpicContract(EpicStoreContract, unittest.TestCase): store.change(key, by_loop=False) return key - def score(self, store: MemoryEpic, key: str, scores: dict[str, str]) -> None: # type: ignore[override] - store.change(key, scores=jira_epic.scores(key, scores)) + def score(self, store: MemoryEpic, key: str, scores: dict[str, object]) -> None: # type: ignore[override] + read = jira_epic.scores(key, scores) + assert not isinstance(read, Failure), read + store.change(key, scores=read.scores, moves=read.moves, exempt=read.exempt) def block(self, store: MemoryEpic, key: str, blocker: str) -> None: # type: ignore[override] store.change(key, blockers=(*next(issue for issue in store.issues if issue.key == key).blockers, blocker)) diff --git a/bin/do_epic/backend/test_jira.py b/bin/do_epic/backend/test_jira.py index 18ac3f23..015d5514 100644 --- a/bin/do_epic/backend/test_jira.py +++ b/bin/do_epic/backend/test_jira.py @@ -123,7 +123,7 @@ class JiraEpicContract(Case, EpicStoreContract): def person_files(self, store: JiraEpic, summary: str) -> str: # type: ignore[override] return self.jira.person_files(summary) - def score(self, store: JiraEpic, key: str, scores: dict[str, str]) -> None: # type: ignore[override] + def score(self, store: JiraEpic, key: str, scores: dict[str, object]) -> None: # type: ignore[override] held = next(issue for issue in self.jira.issues if issue["key"] == key).get("properties", {}).get("plan-item", {}) # type: ignore[attr-defined, union-attr] self.jira.set_property(key, held | scores) diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 9ffa60ef..2bf47644 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -490,7 +490,7 @@ def issue_of(raw: object) -> Issue | Failure: def blocked_by_links(fields: dict[str, typing.Any]) -> tuple[Link, ...]: - """The "is blocked by" links among an issue's `issuelinks` field; a KeyError, TypeError or AttributeError where it isn't in the shape Jira documents.""" + """The "is blocked by" links among an issue's `issuelinks` field. A field not in the shape Jira documents raises a KeyError or TypeError, which the caller turns into a Failure.""" return tuple(Link(link["inwardIssue"]["key"], link["id"]) for link in fields["issuelinks"] if "inwardIssue" in link and link["type"]["inward"] == "is blocked by")