test_version_lock.py python
48 lines 1.4 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 3 days 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 2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 3 days ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 55 days ago