| 1234567891011121314151617181920212223242526272829 |
- """Assert that config-all.json matches what gen_example_config.py produces.
- Fails when a new configurable item is added (to a dataclass or to config.json)
- but config-all.json hasn't been regenerated. Fix by running the pre-commit hook
- or: uv run python scripts/gen_example_config.py > room_cal/config-all.json
- """
- import importlib.util
- from pathlib import Path
- _ROOT = Path(__file__).parent.parent
- def _load_generator():
- spec = importlib.util.spec_from_file_location(
- 'gen_example_config',
- _ROOT / 'scripts' / 'gen_example_config.py',
- )
- mod = importlib.util.module_from_spec(spec)
- spec.loader.exec_module(mod)
- return mod
- def test_config_all_is_current():
- generated = _load_generator().generate().strip()
- committed = (_ROOT / 'room_cal' / 'config-all.json').read_text(encoding='utf-8').strip()
- assert generated == committed, (
- 'config-all.json is stale. '
- 'Run: uv run python scripts/gen_example_config.py > room_cal/config-all.json'
- )
|