Test held() and the breaches a commit in the config's folder reports
This commit is contained in:
@@ -10,7 +10,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from failure import Failure
|
||||
from test_env import isolated_env
|
||||
from project_config.settings import load, ProjectConfig
|
||||
from project_config.settings import held, load, ProjectConfig
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parents[1] / "project-config"
|
||||
|
||||
@@ -171,6 +171,21 @@ class LoadTest(ConfigCase):
|
||||
self.assertIsInstance(load(self.checkout, self.checkout, self.home), ProjectConfig)
|
||||
|
||||
|
||||
class HeldTest(ConfigCase):
|
||||
def test_a_configs_folder_holds_its_config_as_the_main_checkout_reads_it(self) -> None:
|
||||
folder = self.write("acme", CLIENT)
|
||||
found = held(folder, self.home)
|
||||
assert isinstance(found, ProjectConfig), found
|
||||
self.assertEqual((found.folder, found.top, found.paths["plan"]), (folder, self.checkout, folder / "todo.md"), "the config's ~/ checkout read under home")
|
||||
|
||||
def test_only_a_folder_under_the_projects_folder_that_holds_a_config_is_one(self) -> None:
|
||||
self.assertIsNone(held(self.home / ".claude-projects" / "empty", self.home), "no config.toml")
|
||||
elsewhere = self.home / "code" / "acme"
|
||||
elsewhere.mkdir()
|
||||
(elsewhere / "config.toml").write_text(CLIENT, encoding="utf-8")
|
||||
self.assertIsNone(held(elsewhere, self.home), "a config.toml outside ~/.claude-projects/")
|
||||
|
||||
|
||||
class ToolTest(ConfigCase):
|
||||
def run_tool(self, *args: str, cwd: pathlib.Path | None = None) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], cwd=cwd or self.checkout, env={**isolated_env(), "HOME": str(self.home)}, capture_output=True, text=True)
|
||||
|
||||
@@ -935,6 +935,7 @@ class TodoRankCheck(unittest.TestCase):
|
||||
self.config.write_text(self.config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"'))
|
||||
(self.config.parent / "todo.md").write_text("# todo\n")
|
||||
self.assertEqual(self.details(folder), [f"own script checked {folder}/todo.md"], "checked with the checkout's own rank_todo.py, as a commit there would be")
|
||||
self.assertEqual([(breach.rule, breach.directory) for breach in todo_breaches(folder, pathlib.Path(self.own))], [("todo-rank-check", str(pathlib.Path(folder).resolve()))])
|
||||
git(folder, "add", "-A")
|
||||
git(folder, "commit", "-q", "-m", "plan")
|
||||
self.assertEqual(self.details(folder), [], "committed, so unchanged")
|
||||
@@ -942,6 +943,16 @@ class TodoRankCheck(unittest.TestCase):
|
||||
(self.config.parent / "todo.md").write_text("# changed\n")
|
||||
self.assertEqual(self.details(folder), [], "a config to fix doesn't block the commit that fixes it")
|
||||
|
||||
def test_a_commit_in_the_configs_folder_of_another_repo_checks_its_plan_with_the_hooks_ranking(self):
|
||||
self.changed_plan(self.other, self.STUB)
|
||||
self.config.write_text(self.config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"'))
|
||||
folder = str(self.config.parent)
|
||||
git(folder, "init", "-q", "-b", "main")
|
||||
(self.config.parent / "todo.md").write_text("# todo\n")
|
||||
reasons = self.details(folder)
|
||||
self.assertTrue(reasons)
|
||||
self.assertNotIn("own script", " ".join(reasons))
|
||||
|
||||
def test_a_plan_in_a_folder_of_the_checkout_is_checked_once_it_changes(self):
|
||||
checkout = self.changed_plan(f"{self.folder}/clone", self.STUB)
|
||||
self.config.write_text(self.config.read_text().replace('"checkout:todo.md"', '"checkout:plan/todo.md"'))
|
||||
|
||||
Reference in New Issue
Block a user