Answer stability round 1: 1 🔴, 4 🟡 (0 misread); run the stranded held_at test, and test a blocked row, an edit without a detail and an ID that prefixes another

This commit is contained in:
2026-11-14 16:01:53 +01:00
parent 0cb2cbabcd
commit d6e8b7b105
4 changed files with 25 additions and 8 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ def same_origin(clone: str, checkout: str) -> Failure | None:
def clone_plan(clone: str) -> FilePlan:
"""The clone's plan, with each file ranking reads, at the paths this repo keeps them."""
"""The clone's plan, at the path this repo keeps it. ready_release only reads it; FilePlan also takes the files a write would rank it against."""
decisions, history = (FileStore(pathlib.Path(clone, path), path) for path in ("docs/decisions.md", "docs/comprehension-history.md"))
return FilePlan(pathlib.Path(clone, "todo.md"), "todo.md", pathlib.Path(clone, "README.md"), decisions, history)
+2 -1
View File
@@ -11,7 +11,7 @@ SECOND = {"Release": "0.2.0", TAGLINE: "Ship the later thing.", "L": "2", "E": "
class PlanStoreContract:
"""Runs against the store new_store returns: a plan that holds no item yet, and whose goals number a goal 1."""
"""Runs against the store new_store returns: a plan that holds no item yet. The project's goals file must hold a goal numbered 1, which the test items move."""
assertEqual: typing.Callable[..., None]
assertIsInstance: typing.Callable[..., None]
assertNotEqual: typing.Callable[..., None]
@@ -70,6 +70,7 @@ class PlanStoreContract:
id_ = self.filed(store, FIRST)
store.edit(id_, {"Release": "0.3.0"}, None)
self.assertEqual(self.items(store)[id_].release, release_of("0.3.0"))
self.assertEqual(self.items(store)[id_].detail, "")
def test_finish_removes_the_item_and_keeps_the_others(self) -> None:
store = self.new_store()
+19 -3
View File
@@ -1,4 +1,5 @@
import dataclasses
import os
import pathlib
import sys
import tempfile
@@ -71,6 +72,17 @@ class FilePlan(FilePlanContract):
self.assertEqual([note.split(": ")[0] for note in written.notes], [str(self.folder / "todo.md")])
self.assertIn("item 1 ", written.notes[0])
def test_only_the_item_written_refuses_the_write(self):
store = self.new_store()
first = self.filed(store, FIRST)
todo = self.folder / "todo.md"
todo.write_text(todo.read_text().replace("`Next ID = 2`", "`Next ID = 10`"))
self.assertEqual(self.filed(store, FIRST), 10)
todo.write_text("".join(line.replace("| 4 | 1 | 1 by 9 |", "| 4 | 10 | 1 by 9 |") if line.startswith("| 10 ") else line for line in todo.read_text().splitlines(keepends=True)))
written = store.edit(first, {"E": "2"}, None)
assert isinstance(written, stores.Written), written
self.assertIn("item 10 ", written.notes[0])
def test_a_missing_file_fails_naming_it(self):
store = self.new_store()
(self.folder / "todo.md").unlink()
@@ -104,6 +116,7 @@ class FilePlan(FilePlanContract):
self.assertEqual(store.edit(id_, {}, "### Why\n"), Failure(split))
self.assertEqual((self.folder / "todo.md").read_text(), before)
@unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory")
def test_a_file_it_cannot_write_fails_naming_it(self):
store = self.new_store()
self.folder.chmod(0o555)
@@ -140,9 +153,12 @@ class HeldAt(unittest.TestCase):
self.assertEqual(stores.held_at("origin/main", held, "/checkout", run), held.read())
def test_fails_where_the_revision_cannot_be_read(self):
def run(*args, cwd):
return Failure("no git") if args[0] == "ls-tree" else "a commit\n"
self.assertEqual(stores.held_at("origin/main", MemoryPlan(tracked="todo.md"), "/checkout", run), Failure("no git"))
if __name__ == "__main__":
unittest.main()
def test_fails_where_the_revision_cannot_be_read(self):
self.assertEqual(stores.held_at("origin/main", MemoryPlan(tracked="todo.md"), "/checkout", lambda *args, cwd: Failure("no git")), Failure("no git"))