import json
import pytest

from scripts.mindmodel import loader


def test_load_json_manifest(tmp_path):
    data = [{"id": "c1", "description": "a constraint"}]
    p = tmp_path / "manifest.json"
    p.write_text(json.dumps(data), encoding="utf-8")

    loaded = loader.load_manifest(str(p))

    assert isinstance(loaded, dict)
    assert "constraints" in loaded
    assert any(c.get("id") == "c1" for c in loaded["constraints"])


def test_missing_manifest_raises():
    with pytest.raises(loader.ManifestLoadError):
        loader.load_manifest("nonexistent-file-manifest.json")
