|
@@ -52,7 +52,7 @@ def test_env():
|
|
|
|
|
|
def test_agent_state_change(test_env):
|
|
def test_agent_state_change(test_env):
|
|
service, _ = test_env
|
|
service, _ = test_env
|
|
- agent = service._get_agent_instance('staff_id_0', 'user_id_0')
|
|
|
|
|
|
+ agent = service.get_agent_instance('staff_id_0', 'user_id_0')
|
|
assert agent.current_state == DialogueState.INITIALIZED
|
|
assert agent.current_state == DialogueState.INITIALIZED
|
|
assert agent.previous_state == DialogueState.INITIALIZED
|
|
assert agent.previous_state == DialogueState.INITIALIZED
|
|
|
|
|
|
@@ -110,7 +110,7 @@ def test_response_sanitization(test_env):
|
|
def test_normal_conversation_flow(test_env):
|
|
def test_normal_conversation_flow(test_env):
|
|
"""测试正常对话流程"""
|
|
"""测试正常对话流程"""
|
|
service, queues = test_env
|
|
service, queues = test_env
|
|
- service._get_agent_instance('staff_id_0', "user_id_0").message_aggregation_sec = 0
|
|
|
|
|
|
+ service.get_agent_instance('staff_id_0', "user_id_0").message_aggregation_sec = 0
|
|
|
|
|
|
# 准备测试消息
|
|
# 准备测试消息
|
|
test_msg = Message.build(
|
|
test_msg = Message.build(
|
|
@@ -132,7 +132,7 @@ def test_normal_conversation_flow(test_env):
|
|
def test_aggregated_conversation_flow(test_env):
|
|
def test_aggregated_conversation_flow(test_env):
|
|
"""测试聚合对话流程"""
|
|
"""测试聚合对话流程"""
|
|
service, queues = test_env
|
|
service, queues = test_env
|
|
- service._get_agent_instance('staff_id_0', "user_id_0").message_aggregation_sec = 1
|
|
|
|
|
|
+ service.get_agent_instance('staff_id_0', "user_id_0").message_aggregation_sec = 1
|
|
|
|
|
|
# 准备测试消息
|
|
# 准备测试消息
|
|
ts_begin = int(time.time() * 1000)
|
|
ts_begin = int(time.time() * 1000)
|
|
@@ -175,7 +175,7 @@ def test_aggregated_conversation_flow(test_env):
|
|
def test_human_intervention_trigger(test_env):
|
|
def test_human_intervention_trigger(test_env):
|
|
"""测试触发人工干预"""
|
|
"""测试触发人工干预"""
|
|
service, queues = test_env
|
|
service, queues = test_env
|
|
- service._get_agent_instance('staff_id_0',"user_id_0").message_aggregation_sec = 0
|
|
|
|
|
|
+ service.get_agent_instance('staff_id_0', "user_id_0").message_aggregation_sec = 0
|
|
|
|
|
|
# 准备需要人工干预的消息
|
|
# 准备需要人工干预的消息
|
|
test_msg = Message.build(
|
|
test_msg = Message.build(
|
|
@@ -201,11 +201,11 @@ def test_human_intervention_trigger(test_env):
|
|
def test_initiative_conversation(test_env):
|
|
def test_initiative_conversation(test_env):
|
|
"""测试主动发起对话"""
|
|
"""测试主动发起对话"""
|
|
service, queues = test_env
|
|
service, queues = test_env
|
|
- service._get_agent_instance('staff_id_0', "user_id_0").message_aggregation_sec = 0
|
|
|
|
|
|
+ service.get_agent_instance('staff_id_0', "user_id_0").message_aggregation_sec = 0
|
|
service._call_chat_api = Mock(return_value="主动发起模拟消息")
|
|
service._call_chat_api = Mock(return_value="主动发起模拟消息")
|
|
|
|
|
|
# 设置Agent需要主动发起对话
|
|
# 设置Agent需要主动发起对话
|
|
- agent = service._get_agent_instance('staff_id_0', "user_id_0")
|
|
|
|
|
|
+ agent = service.get_agent_instance('staff_id_0', "user_id_0")
|
|
agent.should_initiate_conversation = Mock(return_value=(True, MagicMock()))
|
|
agent.should_initiate_conversation = Mock(return_value=(True, MagicMock()))
|
|
# 发起对话有时间限制
|
|
# 发起对话有时间限制
|
|
agent.get_time_context = Mock(return_value=TimeContext.MORNING)
|
|
agent.get_time_context = Mock(return_value=TimeContext.MORNING)
|