from __future__ import annotations

import sys
import unittest
from pathlib import Path

HERE = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(HERE))

import publication_gate  # noqa: E402


class PublicationGateTests(unittest.TestCase):
    def test_required_clean_room_matrix_is_comprehensive(self):
        for key in (
            "contractSuites", "invariantSuites", "arithmeticSuites",
            "sdkBuildAndTests", "apiBuildAndTests", "siteBuildAndTests",
            "solanaReproducibleChecks", "x402Discovery", "x402Unpaid402",
            "x402ReceiptBehavior", "v2AbiCompatibility",
            "v2RuntimeCompatibility", "migrationLedger",
        ):
            self.assertIn(key, publication_gate.CLEAN_ROOM_KEYS)

    def test_empty_pass_map_fails_closed(self):
        errors = publication_gate.require_pass_map(
            "cleanRoom.prePush", {}, publication_gate.CLEAN_ROOM_KEYS
        )
        self.assertEqual(len(publication_gate.CLEAN_ROOM_KEYS), len(errors))

    def test_final_gate_is_currently_blocked(self):
        self.assertTrue(publication_gate.check("final"))


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