from __future__ import annotations

import unittest
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


class LayoutTests(unittest.TestCase):
    def test_dockerfile_and_compose_exist(self) -> None:
        self.assertTrue((ROOT / "Dockerfile").is_file())
        self.assertTrue((ROOT / "compose.yaml").is_file())
        self.assertTrue((ROOT / "requirements.txt").read_text(encoding="utf-8").startswith("cryptography=="))
        dockerfile = (ROOT / "Dockerfile").read_text(encoding="utf-8")
        self.assertIn("10002", dockerfile)
        self.assertIn("8766", dockerfile)
        self.assertIn("livez", dockerfile)

    def test_reserved_adapters_present(self) -> None:
        from datahub.adapters import RESERVED

        for name in ("eastmoney", "tencent", "ths", "xgb", "akshare", "ifind"):
            self.assertIn(name, RESERVED)
            probe = RESERVED[name].probe()
            self.assertEqual(probe["state"], "reserved")
            self.assertFalse(probe["configured"])


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