StrayWarrior 1 день назад
Родитель
Сommit
5d9f8525b1
1 измененных файлов с 11 добавлено и 3 удалено
  1. 11 3
      tests/unit_test.py

+ 11 - 3
tests/unit_test.py

@@ -4,8 +4,11 @@
 
 import pytest
 from unittest.mock import Mock, MagicMock
-from pqai_agent.agent_service import AgentService, MemoryQueueBackend
+
+import pqai_agent.abtest.client
+from pqai_agent.agent_service import AgentService
 from pqai_agent.dialogue_manager import DialogueState, TimeContext
+from pqai_agent.message_queue_backend import MemoryQueueBackend
 from pqai_agent.mq_message import MessageType, MqMessage, MessageChannel
 from pqai_agent.response_type_detector import ResponseTypeDetector
 from pqai_agent.user_manager import LocalUserManager
@@ -44,11 +47,16 @@ def test_env():
         user_relation_manager=user_relation_manager
     )
     service.user_profile_extractor.extract_profile_info = Mock(return_value=None)
+    service.can_send_to_user = Mock(return_value=True)
+    service.start()
 
     # 替换LLM调用为模拟响应
     service._call_chat_api = Mock(return_value="模拟响应")
 
-    return service, queues
+    yield service, queues
+
+    service.shutdown(sync=True)
+    pqai_agent.abtest.client.get_client().shutdown(blocking=True)
 
 def test_agent_state_change(test_env):
     service, _ = test_env
@@ -220,7 +228,7 @@ def test_initiative_conversation(test_env):
 def test_response_type_detector(test_env):
     case1 = '大哥,那可得提前了解下天气,以便安排行程~我帮您查查明天北京天气?'
     assert ResponseTypeDetector.is_chinese_only(case1) == True
-    assert ResponseTypeDetector.if_message_suitable_for_voice(case1) == False
+    assert ResponseTypeDetector.if_message_suitable_for_voice(case1) == True
     case2 = 'hi'
     assert ResponseTypeDetector.is_chinese_only(case2) == False
     case3 = '这是链接:http://domain.com'