#!/usr/bin/env python3
"""Regression checks for the fail-closed pilot-gate report."""
from __future__ import annotations

import json
import subprocess
import sys
import unittest
from pathlib import Path

PILOT_DIR = Path(__file__).resolve().parent
CHECKER = PILOT_DIR / "check_pilot_gate.py"


class PilotGateCheckerTest(unittest.TestCase):
    def test_checked_in_evidence_template_never_passes(self) -> None:
        output = subprocess.check_output([sys.executable, str(CHECKER)], text=True)
        report = json.loads(output)
        self.assertTrue(report["artifactPresenceIsNotAPass"])
        self.assertFalse(report["localArtifactGatePassed"])
        self.assertFalse(report["pilotReady"])
        self.assertEqual(report["executableEvidencePassed"], 0)
        self.assertEqual(len(report["executableEvidenceFailed"]), report["totalChecks"])
        self.assertTrue(report["externalEvidenceFailed"])


if __name__ == "__main__":
    unittest.main()
