feat(mindmodel): add CLI wrapper, edge-case tests, and manifest schema tests

This commit is contained in:
2026-03-24 22:41:28 +01:00
parent ed289ff582
commit d1faf2b3e4
5 changed files with 225 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import re
from pathlib import Path
try:
import yaml # type: ignore
except Exception:
yaml = None
def test_manifest_loads():
"""Ensure the .mindmodel/manifest.yaml can be read and contains a 'files' list."""
p = Path(".mindmodel/manifest.yaml")
assert p.exists(), ".mindmodel/manifest.yaml must exist"
text = p.read_text(encoding="utf-8")
if yaml is not None:
data = yaml.safe_load(text)
assert isinstance(data, dict), "manifest should parse to a mapping"
assert "files" in data, "top-level 'files' key missing"
assert isinstance(data["files"], list), "'files' should be a list"
assert len(data["files"]) >= 1, "'files' must have at least one entry"
else:
# Fallback simple checks if PyYAML is not available in the environment.
assert re.search(r"^\s*files:\s*$", text, re.M), (
"manifest must contain top-level 'files:'"
)
assert re.search(r"^\s*-\s+path:\s+", text, re.M), (
"manifest must contain at least one '- path:' entry"
)
+32
View File
@@ -0,0 +1,32 @@
from pathlib import Path
from src.validators.types import parse_manifest
def test_manifest_schema_parses_into_types():
"""Ensure the .mindmodel/manifest.yaml parses via parse_manifest and
yields a manifest-like object with a files list where each entry has a
`path` key.
The test relies on parse_manifest to use its PyYAML fallback when
PyYAML is not available in the test environment.
"""
p = Path(".mindmodel/manifest.yaml")
assert p.exists(), ".mindmodel/manifest.yaml must exist"
manifest = parse_manifest(str(p))
# Accept either a plain mapping or the Manifest dataclass returned by
# parse_manifest. Normalize to the files list for assertions.
if isinstance(manifest, dict):
files = manifest.get("files", [])
else:
# Manifest dataclass has .files attribute
files = getattr(manifest, "files", [])
assert isinstance(files, list), "manifest.files must be a list"
assert files, "manifest must contain at least one file entry"
for entry in files:
assert isinstance(entry, dict), "each file entry should be a mapping"
assert "path" in entry, f"file entry missing 'path': {entry}"