import json
from pathlib import Path

from rm75_ik.validation import load_project_tools, write_validation_report


def test_project_tool_config_and_report_output(tmp_path):
    tools = load_project_tools(
        Path(__file__).resolve().parents[2]
        / "xr_rm_bringup"
        / "config"
        / "peripherals_rm75.yaml"
    )
    assert set(tools) == {"scissor", "omnipic", "minisci"}

    summary = {
        "passed": True,
        "seed": 20260629,
        "realman_api_version": "v1.1.5",
        "failure_count": 0,
        "checks": {
            "example": {
                "passed": True,
                "required": True,
                "samples": 1,
            }
        },
    }
    json_path, csv_path, markdown_path = write_validation_report(
        tmp_path, summary, []
    )

    assert json.loads(json_path.read_text())["passed"] is True
    assert csv_path.read_text().startswith("category,profile,sample")
    assert "Overall: **PASS**" in markdown_path.read_text()
