import json import pathlib import sys import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from settings_filter import cleaned from git_repo import git from repo_checks import ROOT INSTALL = "git config filter.settings.clean bin/settings_filter.py" class Settings(unittest.TestCase): def test_the_stored_settings_hold_no_model_and_sorted_keys(self): # The index, not the working file: the working file holds this machine's model in Claude Code's key order. stored = git("show", ":settings.json", cwd=str(ROOT)) self.assertIsInstance(stored, str, stored) fix = f"commit settings.json with the filter on: {INSTALL}" self.assertNotIn("model", json.loads(stored), fix) self.assertEqual(stored, cleaned(json.loads(stored)), fix) def test_the_readme_installs_the_filter_git_attributes_names_for_the_root_settings_only(self): self.assertEqual("/settings.json filter=settings\n", (ROOT / ".gitattributes").read_text(encoding="utf-8")) self.assertIn(f"{INSTALL}\n", (ROOT / "README.md").read_text(encoding="utf-8"))