feat: 事件异常会话话术与询价消息服务卡片
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -12,6 +12,7 @@ ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
if ROOT not in sys.path:
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
from agent.policy import inquiry_copy as copy
|
||||
from agent.policy.event_exception import (
|
||||
WAIT_ADOPT,
|
||||
WAIT_AIR_QUOTE,
|
||||
@@ -102,5 +103,65 @@ class TestMentions(unittest.TestCase):
|
||||
self.assertEqual(conversation_of(wait_kind=WAIT_DEAL, collab_chat_id=""), "private")
|
||||
|
||||
|
||||
class TestEventExceptionCopy(unittest.TestCase):
|
||||
def test_group_air(self) -> None:
|
||||
text = copy.event_exception_session_text(
|
||||
exception_type="航线响应超时",
|
||||
work_order_no="WO202606180003",
|
||||
names=["张三"],
|
||||
hours=0.25,
|
||||
mention=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
text,
|
||||
"航线响应超时\n关联询价工单 WO202606180003。@张三已超过 0.25 工作小时 无响应,事件异常已记录工单,请及时处理。",
|
||||
)
|
||||
|
||||
def test_group_two_names(self) -> None:
|
||||
text = copy.event_exception_session_text(
|
||||
exception_type="产品响应超时",
|
||||
work_order_no="WO1",
|
||||
names=["张三", "李四"],
|
||||
hours=2,
|
||||
mention=True,
|
||||
)
|
||||
self.assertIn("@张三 @李四已超过 2 工作小时", text)
|
||||
|
||||
def test_private_sales_no_at(self) -> None:
|
||||
text = copy.event_exception_session_text(
|
||||
exception_type="销售响应超时",
|
||||
work_order_no="WO1",
|
||||
names=["王五"],
|
||||
hours=48,
|
||||
mention=False,
|
||||
)
|
||||
self.assertIn("王五已超过 48 工作小时", text)
|
||||
self.assertNotIn("@王五", text)
|
||||
|
||||
def test_test_prefix(self) -> None:
|
||||
text = copy.event_exception_session_text(
|
||||
exception_type="销售响应超时",
|
||||
work_order_no="WO1",
|
||||
names=["王五"],
|
||||
hours=1,
|
||||
mention=False,
|
||||
test_prefix=True,
|
||||
)
|
||||
self.assertTrue(text.startswith("[test] "))
|
||||
|
||||
def test_app_card(self) -> None:
|
||||
payload = copy.event_exception_alert_payload(
|
||||
card_title="销售响应异常",
|
||||
work_order_no="WO202609090199",
|
||||
hours=48,
|
||||
)
|
||||
self.assertEqual(payload["wecom_app"], "notify")
|
||||
card = payload["template_card"]
|
||||
self.assertEqual(card["source"]["desc"], "询价机器人事件告警")
|
||||
self.assertEqual(card["main_title"]["title"], "销售响应异常")
|
||||
self.assertEqual(card["main_title"]["desc"], "关联询价工单 WO202609090199")
|
||||
self.assertIn("您已超过 48 工作小时无响应", card["sub_title_text"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user