import unittest

from utils.intent_analyzer import detect_intent


class IntentAnalyzerTests(unittest.TestCase):
    def test_keyword_fallback_for_price(self):
        d = detect_intent("这个怎么收费")
        self.assertEqual(d.intent, "询价")
        self.assertEqual(d.source, "keyword")

    def test_keyword_fallback_for_greeting(self):
        d = detect_intent("你好 在吗")
        self.assertEqual(d.intent, "打招呼")
        self.assertEqual(d.source, "keyword")

    def test_unknown_intent(self):
        d = detect_intent("abc123")
        self.assertEqual(d.intent, "")
        self.assertIn(d.source, ("none", ""))


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