From 121aba05ea2cb6531c9f0f0d9c931f58d92445b2 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 16 Nov 2026 02:15:39 +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);=20keep=20the?= =?UTF-8?q?=20comment=20in=20the=20fake=20plan,=20and=20name=20move=20amon?= =?UTF-8?q?g=20the=20writes=20Jira=20may=20have=20taken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/plan_store/fakes.py | 7 ++++++- bin/todo_item/main.py | 12 +++++++----- bin/todo_item/test_todo_item.py | 12 ++++++------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/bin/plan_store/fakes.py b/bin/plan_store/fakes.py index 01d7fff9..24435aa5 100644 --- a/bin/plan_store/fakes.py +++ b/bin/plan_store/fakes.py @@ -12,6 +12,8 @@ class MemoryPlan: """A plan held in memory, as a tracker holds one: in the order filed, unranked, with no bar. Where fails is set, every read and write fails with it as the reason.""" rows: dict[int, dict[str, str]] = dataclasses.field(default_factory=dict) details: dict[int, str] = dataclasses.field(default_factory=dict) + # Each comment an edit gave, under its item's ID, as a tracker posts them on the item's issue. + comments: dict[int, list[str]] = dataclasses.field(default_factory=dict) next_id: int = 1 label: str = "the plan in memory" tracked: str | None = None @@ -29,7 +31,10 @@ class MemoryPlan: def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure: if id_ not in self.rows: return Failure(f"{self.label} holds no item {id_}") - return self.put(id_, self.rows[id_] | cells(fields), self.details.get(id_, "") if detail is None else detail) + written = self.put(id_, self.rows[id_] | cells(fields), self.details.get(id_, "") if detail is None else detail) + if comment is not None and isinstance(written, Written): + self.comments.setdefault(id_, []).append(comment) + return written def finish(self, id_: int) -> Written | Failure: if self.fails or id_ not in self.rows: diff --git a/bin/todo_item/main.py b/bin/todo_item/main.py index 99d2d32a..353e0ece 100644 --- a/bin/todo_item/main.py +++ b/bin/todo_item/main.py @@ -39,11 +39,13 @@ empties the cell. --detail replaces the detail with the text on stdin, and --cle Text on stdin without --detail, and --detail without text on stdin, are refused, so no detail is dropped or wiped by mistake. It prints `Edited item in .` It doesn't write anything where ranking fails or scores the item under the bar. -In a Jira epic, edit changes an issue the loop filed: its summary, description, scores and Fix -Version, and the label `security` with --exempt. It doesn't change a link, so --blocked-by fails. +In a Jira epic, edit changes an issue the loop filed: its summary, description and scores, and +the label `security` with --exempt. It doesn't change a link, so --blocked-by fails. Of an issue a person filed it sets only the scores, --moves and --exempt, and only with --comment. ---comment is posted as a comment on the Jira issue, for the client's team: say why the edit is -made, in the project's language. A todo.md keeps no comment, so there the flag doesn't do anything. +The four scores are set together where the issue holds none yet. +--comment is posted as a comment on the Jira issue, for the client's team, in the project's +language. Jira doesn't show the team the scores, so say that the issue is scored, and why. +A todo.md keeps no comment, so there the flag doesn't do anything. Where Jira takes the edit and then refuses the comment, edit still prints `Edited item …`, and says on stderr to post the comment in Jira. @@ -65,7 +67,7 @@ count as done. An issue that no chunk built is dropped in Jira, not with finish, Exit 2 on bad arguments, and 1, saying why, on any other failure. A message opening `not filed:`, `not edited:`, `not moved:` or `not finished:` means it didn't write anything. The one exception is an add, -an edit or a finish in a Jira epic that Jira didn't answer or answered brokenly: the message then +an edit, a move or a finish in a Jira epic that Jira didn't answer or answered brokenly: the message then says the issue may exist, may have changed or may have moved. """ import argparse diff --git a/bin/todo_item/test_todo_item.py b/bin/todo_item/test_todo_item.py index c89aeb16..39a5ec1a 100644 --- a/bin/todo_item/test_todo_item.py +++ b/bin/todo_item/test_todo_item.py @@ -4,7 +4,6 @@ import pathlib import sys import tempfile import unittest -import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent)) @@ -14,8 +13,9 @@ from project_config.settings import DEFAULT_FLOOR from todo_item import edits, main from failure import Failure from project_config.main import located +from plan_store.fakes import MemoryPlan from release_plan import plan_file, ranking -from plan_store.stores import plan_of, Written +from plan_store.stores import plan_of from todo_item.table import table ADD = ["add", "--release", "0.1.0", "--l", "1", "--e", "1", "--i", "1", "--s", "1", "--moves", "1 by 9", "Count the `a | b` runs."] @@ -419,11 +419,11 @@ class Edit(TodoItem): self.assertEqual(self.run_main("edit", "3", "--comment", "Why.")[::2], (1, "not edited: no flag names a change; todo-item --help lists them\n")) def test_an_edit_hands_the_comment_to_the_plan(self): - for argv, comment in ((["--comment", "A small change."], "A small change."), ([], None)): + for argv, comments in ((["--comment", "A small change."], {3: ["A small change."]}), ([], {})): with self.subTest(argv=argv): - plan = unittest.mock.Mock(label="the plan", edit=unittest.mock.Mock(return_value=Written(3))) - self.assertEqual(main.edit(main.parser().parse_args(["edit", "3", "--l", "3", *argv]), plan, ""), "Edited item 3 in the plan.") - plan.edit.assert_called_once_with(3, {"L": "3"}, None, comment) + plan = MemoryPlan({3: {"Release": "0.1.0", "Item": "**Count the runs.**", "L": "1", "E": "2", "I": "3", "S": "1"}}) + self.assertEqual(main.edit(main.parser().parse_args(["edit", "3", "--l", "3", *argv]), plan, ""), "Edited item 3 in the plan in memory.") + self.assertEqual((plan.rows[3]["L"], plan.comments), ("3", comments)) def test_a_plan_in_a_file_takes_an_edit_with_a_comment_and_keeps_no_comment(self): self.assertEqual(self.run_main("edit", "3", "--l", "3", "--comment", "A small change.")[:2], (0, f"Edited item 3 in {self.todo}.\n"))