from __future__ import annotations

import json
import sys
import unittest
from pathlib import Path

ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))

import tools.validate_kis_token_hygiene_v1 as validator


class TestKisTokenHygieneV1(unittest.TestCase):
    def test_validator_reports_pass(self):
        rc = validator.main()
        self.assertEqual(rc, 0)
        payload = json.loads((ROOT / "Temp" / "kis_token_hygiene_v1.json").read_text(encoding="utf-8"))
        self.assertEqual(payload["gate"], "PASS")
        self.assertIn("sanitized_token_refresh_error", payload["evidence"][str(ROOT / "src" / "quant_engine" / "kis_api_client_v1.py")])


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