Files
claude-config/bin/repo_checks/test_settings.py
T

40 lines
1.6 KiB
Python

import json
import pathlib
import sys
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from claude_home.home import CLONE
from repo_checks import ROOT
class Settings(unittest.TestCase):
def setUp(self) -> None:
self.text = (ROOT / "settings.json").read_text(encoding="utf-8")
self.settings = json.loads(self.text)
def test_the_tracked_settings_hold_no_model_and_sorted_keys(self) -> None:
# A model belongs to the generated settings.json in the loop's Claude home, where /model writes it.
self.assertNotIn("model", self.settings)
self.assertEqual(self.text, json.dumps(self.settings, indent=2, sort_keys=True) + "\n")
def test_every_hook_runs_a_tool_of_the_clone(self) -> None:
commands = [hook["command"] for groups in self.settings["hooks"].values() for group in groups for hook in group["hooks"]]
self.assertTrue(commands)
for command in commands:
self.assertTrue(command.startswith(f"{CLONE}/bin/"), command)
self.assertTrue((ROOT / "bin" / command.split()[0].removeprefix(f"{CLONE}/bin/")).is_file(), command)
def test_the_persons_theme_and_status_line_are_not_set(self) -> None:
self.assertNotIn("theme", self.settings)
self.assertNotIn("statusLine", self.settings)
def test_every_enabled_plugins_marketplace_names_the_repo_the_home_adds_it_from(self) -> None:
enabled = [plugin for plugin, enabled in self.settings["enabledPlugins"].items() if enabled]
self.assertTrue(enabled)
for plugin in enabled:
self.assertRegex(self.settings["extraKnownMarketplaces"][plugin.split("@")[1]]["source"]["repo"], r"^[\w.-]+/[\w.-]+\Z", plugin)