test_version_lock.py
python
sha256:8d7f41aafae41deee70035a92f93602ef1722a290153597451e5932af503a42c
docs: queue board-identity follow-ups so they survive the session
Human
2 hours ago
| 1 | """Unit tests for version.lock reader/writer.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | import pytest |
| 8 | |
| 9 | from cli.version_lock import ( |
| 10 | LockError, |
| 11 | build_version_lock, |
| 12 | read_version_lock, |
| 13 | write_version_lock, |
| 14 | ) |
| 15 | |
| 16 | |
| 17 | def test_round_trip(tmp_path: Path) -> None: |
| 18 | lock = build_version_lock( |
| 19 | kit_version="0.1.0", |
| 20 | config_version=1, |
| 21 | footprint=[("docs/A.md", "templates/A.template.md", b"hello\n")], |
| 22 | ) |
| 23 | path = tmp_path / "version.lock" |
| 24 | write_version_lock(path, lock) |
| 25 | loaded = read_version_lock(path) |
| 26 | assert loaded.kit_version == "0.1.0" |
| 27 | assert len(loaded.footprint) == 1 |
| 28 | assert loaded.footprint[0].path == "docs/A.md" |
| 29 | |
| 30 | |
| 31 | def test_unknown_lock_version_raises(tmp_path: Path) -> None: |
| 32 | path = tmp_path / "version.lock" |
| 33 | path.write_text( |
| 34 | "lock_version: 99\nkit_version: 0.1.0\nconfig_version: 1\n" |
| 35 | 'installed_at: "2026-01-01T00:00:00Z"\n' |
| 36 | 'synced_at: "2026-01-01T00:00:00Z"\n' |
| 37 | 'footprint_digest: "sha256:00"\nfootprint: []\n', |
| 38 | encoding="utf-8", |
| 39 | ) |
| 40 | with pytest.raises(LockError, match="unsupported lock_version"): |
| 41 | read_version_lock(path) |
| 42 | |
| 43 | |
| 44 | def test_missing_keys_raises(tmp_path: Path) -> None: |
| 45 | path = tmp_path / "version.lock" |
| 46 | path.write_text("lock_version: 1\n", encoding="utf-8") |
| 47 | with pytest.raises(LockError, match="missing required key"): |
| 48 | read_version_lock(path) |
File History
1 commit
sha256:8d7f41aafae41deee70035a92f93602ef1722a290153597451e5932af503a42c
docs: queue board-identity follow-ups so they survive the session
Human
2 hours ago