import unittest

from lib.key_monitor.key_monitor_lib import (
    KEY_MONITOR_RS_TYPE,
    is_rs_key_monitor_type,
    rs_monitor_type_for_storage,
    rs_monitor_type_label,
)


class KeyMonitorRsTypeTests(unittest.TestCase):
    def test_legacy_types_still_recognized(self):
        self.assertTrue(is_rs_key_monitor_type("关键阻力位"))
        self.assertTrue(is_rs_key_monitor_type("关键支撑位"))

    def test_storage_normalizes_to_unified_type(self):
        self.assertEqual(rs_monitor_type_for_storage("关键阻力位"), KEY_MONITOR_RS_TYPE)
        self.assertEqual(rs_monitor_type_for_storage("关键支撑位"), KEY_MONITOR_RS_TYPE)
        self.assertEqual(rs_monitor_type_for_storage(KEY_MONITOR_RS_TYPE), KEY_MONITOR_RS_TYPE)

    def test_label_merges_legacy_display(self):
        self.assertEqual(rs_monitor_type_label("关键阻力位"), KEY_MONITOR_RS_TYPE)
        self.assertEqual(rs_monitor_type_label("箱体突破"), "箱体突破")


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