Answer stability round 2: 0 🔴, 1 🟡; test the refusal on a ref that doesn't exist instead of a mock, and say why only Next names a release to empty
This commit is contained in:
@@ -30,11 +30,11 @@ def work_landed(release: tuple[int, int, int], shipped: list[Item], landed: tupl
|
||||
|
||||
|
||||
def landed_towards(found: list[Item], cut: LastCut) -> tuple[int, int, int] | None | Failure:
|
||||
"""The release unreleased changes on the default branch have landed towards: the next release, as chunk-preflight names it (`chunk_pick.chunk_item`), where `chunk_pick.unreleased_changes` counts one or more. None where there is no such release or no such change; a Failure where either cannot be read. found is the default branch's plan."""
|
||||
"""The release unreleased changes on the default branch have landed towards: the next release, as chunk-preflight names it (`chunk_pick.chunk_item`), where it holds items and `chunk_pick.unreleased_changes` counts one or more. None otherwise; a Failure where either cannot be read. found is the default branch's plan."""
|
||||
pick = chunk_item(found, cut)
|
||||
if isinstance(pick, Unknown):
|
||||
return Failure("could not tell the next release from the default branch's tags and todo.md history")
|
||||
# Next is the one pick with a release that holds items; Cut, Finished and Unplanned have none to empty.
|
||||
# Only Next names a release a chunk can empty after work landed: Cut's is already cut, and Finished's and Unplanned's hold no item.
|
||||
if not isinstance(pick, Next):
|
||||
return None
|
||||
changes = unreleased_changes(cut)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import decimal
|
||||
import itertools
|
||||
from unittest import mock
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
@@ -15,11 +14,11 @@ from larv_review.agreement import agreement_report, ruling_agreement, run_agreem
|
||||
from comprehension_history import appended, entries, HistoryChange, latest_places, Place, recorded, ruling_entry, scoring_entry, ScoringRun, Seat
|
||||
import comprehension_history
|
||||
from larv_review.ruling import counted, ruling, split, votes
|
||||
from chunk_pick import DefaultPlan, LastCut
|
||||
from failure import Failure
|
||||
from test_env import isolated_env
|
||||
from todo_table import Item, items, NoItemsTable
|
||||
from larv_review.plan import landed_towards, plan_reasons, scoring_run_due
|
||||
from chunk_pick import LastCut
|
||||
from larv_review.scoring import means, under_floor
|
||||
from larv_review.ruling_base import measured_commit
|
||||
from larv_review.seats import score_line, scores, seats_file
|
||||
@@ -319,7 +318,7 @@ class LandedTowards(unittest.TestCase):
|
||||
self.assertEqual(landed_towards(plan, LastCut("v0.1.0", "", 3, [])), (0, 2, 0))
|
||||
self.assertEqual(landed_towards(plan, LastCut(None, "", 0, [])), None)
|
||||
|
||||
def test_names_no_release_where_chunk_preflight_names_none_that_holds_items(self):
|
||||
def test_names_no_release_where_chunk_preflight_names_none_a_chunk_can_empty(self):
|
||||
changelog = "# Changelog\n\n## Unreleased\n\n- Did a thing.\n"
|
||||
self.assertIsNone(landed_towards([item(1, (0, 1, 0))], LastCut("v0.1.0", changelog, 0, [])))
|
||||
self.assertIsNone(landed_towards([], LastCut("v0.1.0", changelog, 0, [""])))
|
||||
@@ -417,11 +416,9 @@ class LarvReviewTool(unittest.TestCase):
|
||||
self.assertEqual(self.run_tool("needs-scoring-run").stdout, "Scoring run due: the chunk leaves release 0.1.0 with no plan item.\n")
|
||||
|
||||
def test_refuses_where_the_default_branchs_unreleased_changes_cannot_be_read(self):
|
||||
unreadable = DefaultPlan((self.checkout / "todo.md").read_text(), LastCut("v0.0.1", Failure("changelog unreadable"), Failure("count unreadable"), []))
|
||||
self.addCleanup(os.chdir, os.getcwd())
|
||||
os.chdir(self.checkout)
|
||||
with mock.patch("larv_review.plan.default_plan", return_value=unreadable):
|
||||
self.assertEqual(plan_reasons("main", []), Failure("count unreadable"))
|
||||
self.assertIsInstance(plan_reasons("no-such-ref", []), Failure)
|
||||
|
||||
def test_refuses_a_checkout_plan_whose_renamed_section_does_not_parse(self):
|
||||
self.commit("Break the mark", {"todo.md": todo("| 1 | 0.2.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |") + "\n## Renamed\n\nsoon\n"})
|
||||
|
||||
Reference in New Issue
Block a user