Keep the history's writer beside its reader, read plan rows with rank_todo, and fetch only for commands that read the default branch
This commit is contained in:
+13
-9
@@ -9,11 +9,12 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from larv_review.history import appended, entries, entry_text, Place, scoring_runs
|
||||
from larv_review.history import appended, entries, Place, ruling_entry, scoring_runs
|
||||
from failure import Failure
|
||||
from larv_review.rules import first_ruling, HistoryChange, means, measured_commit, plan_items, PlanItem, round_counts, scoring_run_due, under_floor
|
||||
from larv_review.rules import first_ruling, HistoryChange, means, measured_commit, plan_items, round_counts, ruling, scoring_run_due, under_floor, votes
|
||||
from test_loop_claude_black_box import host_env
|
||||
from larv_review.seats import report, ruling, scores, Seat, votes
|
||||
from rank_todo import Item
|
||||
from larv_review.seats import report, scores, Seat
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parent / "larv-review"
|
||||
SCORING = "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\n| Seat | Overall |\n|---|---|\n| Mean | 7.00 |\n"
|
||||
@@ -23,8 +24,8 @@ def paired(time: str, verdict: str, commit: str = "bbbbbbb") -> str:
|
||||
return f"## {time}, PR #2 at {commit}, against aaaaaaa\n\nRuling: {verdict}\n"
|
||||
|
||||
|
||||
def item(id_: int, release: tuple[int, int, int], tagline: str = "**Do it.**") -> PlanItem:
|
||||
return PlanItem(id_, release, tagline)
|
||||
def item(id_: int, release: tuple[int, int, int], tagline: str = "**Do it.**") -> Item:
|
||||
return Item(id_, release, "", tagline, {"R": 1, "S": 1, "A": 1, "G": 1}, ("1",))
|
||||
|
||||
|
||||
def todo(*rows: str) -> str:
|
||||
@@ -83,10 +84,12 @@ class Seats(unittest.TestCase):
|
||||
|
||||
class History(unittest.TestCase):
|
||||
def test_reads_back_what_it_writes(self):
|
||||
ruled = entry_text("2026-10-08T18:37:21Z, PR #2 at bbbbbbb, against aaaaaaa", ["Ruling: worse"], [["Seat", "Vote"], ["Mid A", "worse"]], [("Mid A, decided by:", ["`bin/a.py:3` `f`: hard, with `:9` `g`"]), ("Inherited architect, decided by:", [])])
|
||||
seats = [Seat("Mid A", "worse", ["`bin/a.py:3` `f`: hard, with `:9` `g`"]), Seat("Inherited architect", "worse", [])]
|
||||
ruled = ruling_entry("2026-10-08T18:37:21Z, PR #2 at bbbbbbb, against aaaaaaa", seats, {"Mid A": "worse", "Inherited architect": "same"}, "worse")
|
||||
history = appended(appended("", SCORING), ruled)
|
||||
self.assertTrue(history.startswith("# Comprehension history\n\n## 2026-10-08T12:00:00Z"))
|
||||
self.assertNotIn("Inherited architect, decided by:", history)
|
||||
self.assertIn("| Inherited architect | same (voted worse, naming no place) |", history)
|
||||
found = entries(history)
|
||||
self.assertEqual([(entry.commit, entry.against, entry.ruling) for entry in found], [("aaaaaaa", None, None), ("bbbbbbb", "aaaaaaa", "worse")])
|
||||
self.assertEqual(found[1].places, [Place("bin/a.py", "f"), Place("bin/a.py", "g")])
|
||||
@@ -113,15 +116,15 @@ class Base(unittest.TestCase):
|
||||
|
||||
class Rounds(unittest.TestCase):
|
||||
def test_counts_each_passs_highest_round(self):
|
||||
counts = round_counts(["Answer prose round 1: x", "Answer full scan round 2: y", "Answer full scan round 1: z", "Answer stability: no round", "Rescore: w"])
|
||||
self.assertEqual((counts["prose"], counts["full scan"], counts["stability"], counts["architecture"]), (1, 2, 0, 0))
|
||||
counts = round_counts(["Answer prose round 1: x", "Answer full scan round 2: y", "Answer full scan round 1: z", "Answer stability: no round", "Answer stabilty round 1: typo", "Rescore: w"])
|
||||
self.assertEqual((counts["prose"], counts["full scan"], counts["stability"], counts["architecture"], counts["stabilty"]), (1, 2, 0, 0, 1))
|
||||
|
||||
|
||||
class ScoringRunDue(unittest.TestCase):
|
||||
def test_reads_each_rows_id_release_and_tagline(self):
|
||||
self.assertEqual(plan_items(todo("| 3 | 0.1.0 | | **Do it.** | 1 | 1 | 1 | 1 | 1 | 9.0 |")), [item(3, (0, 1, 0))])
|
||||
self.assertEqual(plan_items("# todo\n"), [])
|
||||
self.assertIsInstance(plan_items(todo("| x | 0.1.0 | | **Do it.** | 1 | 1 | 1 | 1 | 1 | 9.0 |")), Failure)
|
||||
self.assertIsInstance(plan_items(todo("| 0 | 0.1.0 | | **Do it.** | 1 | 1 | 1 | 1 | 1 | 9.0 |")), Failure)
|
||||
|
||||
def test_is_due_for_an_item_naming_the_floor(self):
|
||||
plan = [item(1, (0, 1, 0), "**Lift the project to the Comprehension floor.**"), item(2, (0, 1, 0))]
|
||||
@@ -228,6 +231,7 @@ class LarvReviewTool(unittest.TestCase):
|
||||
self.assertEqual(ran.stdout.splitlines()[0], "Ruling: same. Votes as counted: Mid A worse, Inherited architect same, Maintainability senior worse, Junior A same.")
|
||||
recorded = entries(history.read_text())
|
||||
self.assertEqual([(entry.commit, entry.against, entry.ruling) for entry in recorded], [("abc1234", "def5678", "same")])
|
||||
self.assertEqual(recorded[0].places, [Place("bin/a.py", "f")] * 2)
|
||||
self.assertIn("| Junior A | same (voted worse, naming no place) |", history.read_text())
|
||||
|
||||
def test_records_a_scoring_run_with_its_means(self):
|
||||
|
||||
Reference in New Issue
Block a user