Files
GEWU/tests/api/test_agent_contract.py
T
2026-10-14 19:21:35 +08:00

32 lines
1.0 KiB
Python

import json
from pathlib import Path
from scripts.export_agent_contract import PACK, build_contract
def test_pack_mcp_contract_matches_the_live_server_and_generated_schemas(
tmp_path: Path,
) -> None:
snapshot_path = PACK / "contracts" / "service-v1.json"
snapshot = json.loads(snapshot_path.read_text(encoding="utf-8"))
actual = build_contract(tmp_path)
assert actual == snapshot
assert (PACK / "contracts" / "catalog-v1.json").read_bytes() == (
Path(__file__).resolve().parents[2] / "schema" / "v1" / "catalog.json"
).read_bytes()
packaged_schemas = PACK / "contracts"
for schema in snapshot["record_schemas"]:
schema_path = packaged_schemas / schema["path"]
assert schema_path.is_file()
assert (
schema_path.read_bytes()
== (
Path(__file__).resolve().parents[2]
/ "schema"
/ "v1"
/ "records"
/ Path(schema["path"]).name
).read_bytes()
)