Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s

This commit is contained in:
2026-11-19 12:42:03 +01:00
parent 8ca612b7a4
commit cb3135bc8c
124 changed files with 1437 additions and 793 deletions
+16 -8
View File
@@ -16,15 +16,23 @@ from todo_item.doubles import READABLE_TOUCHES, UNREADABLE_BULLETS
class Main(unittest.TestCase):
# The home of a test that writes no config.
home = pathlib.Path("/no-home")
def configured(self, checkout: str) -> pathlib.Path:
folder = configured(self, pathlib.Path(checkout))
self.home = folder.parents[1]
return folder
def run_main(self, *argv):
with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()) as said:
code = rank_todo.main(list(argv))
code = rank_todo.main(list(argv), self.home)
return code, said.getvalue()
def test_ranks_the_file_in_place_and_check_writes_nothing(self):
with tempfile.TemporaryDirectory() as temp:
todo = pathlib.Path(temp, "todo.md")
configured(self, pathlib.Path(temp))
self.configured(temp)
self.enterContext(contextlib.chdir(temp))
todo.write_text(TODO)
pathlib.Path(temp, "README.md").write_text(README)
@@ -43,7 +51,7 @@ class Main(unittest.TestCase):
def test_ranks_the_plan_and_reads_the_decisions_where_the_config_puts_them(self):
with tempfile.TemporaryDirectory() as temp:
folder = configured(self, pathlib.Path(temp))
folder = self.configured(temp)
self.enterContext(contextlib.chdir(temp))
config = folder / "config.toml"
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"').replace('"checkout:docs/decisions.md"', '"folder:decisions.md"'))
@@ -61,7 +69,7 @@ class Main(unittest.TestCase):
def test_refuses_a_project_whose_plan_is_in_jira_and_writes_no_file(self):
with tempfile.TemporaryDirectory() as temp:
config = configured(self, pathlib.Path(temp)) / "config.toml"
config = self.configured(temp) / "config.toml"
self.enterContext(contextlib.chdir(temp))
config.write_text(config.read_text().replace('"checkout:todo.md"', '"jira:https://acme.atlassian.net/browse/ABC-12"') + 'env-file = "~/acme.env"\njira-score-formula = "V"\njira-score-bar = 1\n')
todo = pathlib.Path(temp, "todo.md")
@@ -74,7 +82,7 @@ class Main(unittest.TestCase):
def test_refuses_a_file_that_is_not_the_plan_the_config_names_and_a_checkout_no_config_names(self):
with tempfile.TemporaryDirectory() as temp:
folder = configured(self, pathlib.Path(temp))
folder = self.configured(temp)
self.enterContext(contextlib.chdir(temp))
pathlib.Path(temp, "todo.md").write_text(TODO)
pathlib.Path(temp, "README.md").write_text(README)
@@ -94,7 +102,7 @@ class Main(unittest.TestCase):
under = "item 2 scores 3.1, under the bar 4; delete it, or mark it with a reason the bar does not apply"
with tempfile.TemporaryDirectory() as temp:
todo = pathlib.Path(temp, "todo.md")
configured(self, pathlib.Path(temp))
self.configured(temp)
self.enterContext(contextlib.chdir(temp))
todo.write_text(TODO.replace("`Bar = 2`", "`Bar = 4`"))
pathlib.Path(temp, "README.md").write_text(README)
@@ -106,7 +114,7 @@ class Main(unittest.TestCase):
def test_check_fails_on_each_item_whose_touches_list_it_cannot_read(self):
with tempfile.TemporaryDirectory() as temp:
todo = pathlib.Path(temp, "todo.md")
configured(self, pathlib.Path(temp))
self.configured(temp)
self.enterContext(contextlib.chdir(temp))
pathlib.Path(temp, "README.md").write_text(README)
pathlib.Path(temp, "docs").mkdir()
@@ -125,7 +133,7 @@ class Main(unittest.TestCase):
def test_says_to_reshape_an_old_shape_table_but_passes_the_check(self):
with tempfile.TemporaryDirectory() as temp:
todo = pathlib.Path(temp, "todo.md")
configured(self, pathlib.Path(temp))
self.configured(temp)
self.enterContext(contextlib.chdir(temp))
todo.write_text(OLD_SHAPE)
pathlib.Path(temp, "README.md").write_text(README)