Files
mlx-knife/tests_2.0/spec/test_spec_version_sync.py
Local Test 2624210353 Consolidate JSON API; add --version; health in list/show (spec json-0.1.2)
- Enforce strict JSON API in tests
- Introduce --version --json as sole version reporter
2025-08-31 15:17:19 +02:00

27 lines
871 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Ensures the codes spec version matches docs/json-api-specification.md.
This enforces discipline: Spec, code, and tests must evolve together.
"""
from pathlib import Path
import re
import pytest
from mlxk2.spec import JSON_API_SPEC_VERSION
@pytest.mark.spec
def test_spec_version_matches_docs():
docs_path = Path("docs/json-api-specification.md")
assert docs_path.exists(), "Spec document missing"
content = docs_path.read_text(encoding="utf-8")
# Extract the version from the first lines like: **Specification Version:** 0.1.2
m = re.search(r"\*\*Specification Version:\*\*\s*([0-9]+\.[0-9]+\.[0-9]+)", content)
assert m, "Could not parse spec version from docs"
docs_version = m.group(1)
assert (
docs_version == JSON_API_SPEC_VERSION
), f"Spec version mismatch: docs={docs_version} code={JSON_API_SPEC_VERSION}"