import json
import tempfile
import unittest
from pathlib import Path
import sys

sys.path.insert(0, str(Path(__file__).parent))
import check_config
import language_regression
import route_stats


ROOT = Path(__file__).parent


class ExampleChecks(unittest.TestCase):
    def test_config_audit_exposes_moe_fields(self):
        lines = check_config.audit(ROOT / "fixtures/config-mini.json")
        self.assertIn("text_config.num_experts=8", lines)
        self.assertIn("text_config.mtp_num_hidden_layers=0", lines)

    def test_route_counts_are_grouped(self):
        out = route_stats.summarize(ROOT / "fixtures/route-events.jsonl")
        self.assertEqual(out["by_language"]["es"][1], 1)
        self.assertEqual(out["by_language"]["en"][2], 1)

    def test_language_report_is_external_verdict(self):
        out = language_regression.report(ROOT / "fixtures/language-results.jsonl")
        self.assertEqual(out["es"]["n"], 2)
        self.assertEqual(out["es"]["pass_rate"], 0.5)


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