Start an epic's issues in order of score, scoring each that holds none

This commit is contained in:
Lilleman
2026-11-20 14:30:30 +01:00
parent abaf54bc46
commit 5f2a4b6385
19 changed files with 615 additions and 83 deletions
+18 -1
View File
@@ -7,7 +7,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.ranking import chain, EpicItem, rank_moves, ranked, RepoRanking, reranked
from do_epic.ranking import chain, EpicItem, goals_named, rank_moves, ranked, RepoRanking, reranked
from failure import Failure
from plan.todo_table import Item, parse_moves
from do_epic.backend.fake import MemoryEpic
@@ -55,6 +55,23 @@ class ChainTest(unittest.TestCase):
self.assertEqual(chain("Ship it.\n", None, None), Failure("the epic's ## Goals has no numbered goal"))
class GoalsNamedTest(unittest.TestCase):
EPIC = "1. **Maintain:** Break no import.\n2. **Achieve:** Ship the import.\n"
def test_names_only_the_epics_achieve_goals_for_an_item_without_a_repo(self) -> None:
self.assertEqual(goals_named(self.EPIC, None, None), "The epic's goals, each named `epic <its number>`:\n\n1. **Maintain:** Break no import.\n2. **Achieve:** Ship the import.\n\nAn item moves only these: `epic 2`.")
self.assertTrue(str(goals_named("1. **Maintain:** Break no import.\n", None, None)).endswith("An item moves only these: none, so leave the moves empty."))
def test_names_code_health_and_the_repos_goals_for_an_item_in_a_repo(self) -> None:
own = RepoRanking("## Goals\n\n1. **Achieve:** Serve the API.\n\n## Audience\nIts callers.\n", "", "", decimal.Decimal(7))
found = goals_named(self.EPIC, "api", own)
assert isinstance(found, str), found
self.assertIn("\n\n`code health` is the goal that the code of api stays easy to read, change safely and debug.\n\nThe goals of the repo api, each named `repo <its number>`:\n\n1. **Achieve:** Serve the API.\n\nAn item moves only these: `epic 2`, `code health`, `repo 1`.", found)
def test_fails_on_goals_that_cannot_be_read(self) -> None:
self.assertIsInstance(goals_named(self.EPIC, "api", RepoRanking("No goals here.\n", "", "", decimal.Decimal(7))), Failure)
class RankedTest(unittest.TestCase):
def test_each_goal_weighs_0_97_of_the_one_above_it_in_the_chain(self) -> None:
found = ranked([item(1, "repo 1 by 10"), item(2, "epic 2 by 10"), item(3, "epic 1 by 10")], "V", EPIC_GOALS, {"billing-api": VOIDED})