from __future__ import annotations

import unittest

from backend.bootstrap.config import tushare_code
from backend.features.market import charts


class MarketSymbolNormalizationTests(unittest.TestCase):
    def test_chart_and_market_services_share_one_suffix_converter(self) -> None:
        self.assertIs(charts._stock_market_code, tushare_code)

    def test_existing_exchange_mapping_is_preserved(self) -> None:
        cases = {
            "000001": "000001.SZ",
            "600000": "600000.SH",
            "430047": "430047.BJ",
            "830799": "830799.BJ",
        }
        for code, expected in cases.items():
            with self.subTest(code=code):
                self.assertEqual(charts._stock_market_code(code), expected)


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