from __future__ import annotations

from pathlib import Path

from tools.validate_config import validate_config


REPO_ROOT = Path(__file__).resolve().parents[2]


def test_validate_config_rejects_missing_required_keys(tmp_path: Path) -> None:
    invalid_cfg = tmp_path / "invalid.yaml"
    invalid_cfg.write_text(
        """
meta:
  version: 1
context: {}
states:
  S00:
    action: NONE
    status: PENDING
    desc: missing binding_status
stages: {}
transitions: {}
invariants: {}
""".strip(),
        encoding="utf-8",
    )

    problems, _ = validate_config(invalid_cfg)
    errors = [p for p in problems if p.level == "ERROR"]
    assert errors
    assert any("binding_status" in p.message or "binding_status" in p.path for p in errors)
