207 lines
7.3 KiB
Python
207 lines
7.3 KiB
Python
"""
|
|
陆运核对卡与无产品话术。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
import unittest
|
|
|
|
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
|
|
|
|
|
|
class LandCopyTest(unittest.TestCase):
|
|
def test_domestic_card_no_customs_no_wo(self):
|
|
text = copy.land_confirm_card(
|
|
{
|
|
"运输类型": "国内运输拼车",
|
|
"线路类别": "国内长途/零担",
|
|
"运输分类": "急件",
|
|
"起运港": "广州",
|
|
"目的港": "深圳",
|
|
"品名": "衣服",
|
|
"体积": "100CBM",
|
|
"毛重": "50kg",
|
|
"报价日期": "2026-09-17",
|
|
}
|
|
)
|
|
self.assertIn("始发站(必填):广州", text)
|
|
self.assertNotIn("通关口岸", text)
|
|
self.assertNotIn("WO", text)
|
|
self.assertIn('请回复“确定”进行TMS查价,内容有误时,请重新发内容。', text)
|
|
self.assertIn("运输类型", text)
|
|
self.assertIn("国内运输拼车", text)
|
|
|
|
def test_cross_empty_customs(self):
|
|
text = copy.land_confirm_card(
|
|
{
|
|
"运输类型": "跨境集拼",
|
|
"线路类别": "东南亚",
|
|
"运输分类": "急件",
|
|
"起运港": "广州",
|
|
"目的港": "河内",
|
|
"品名": "衣服",
|
|
"体积": "100CBM",
|
|
"毛重": "50kg",
|
|
"报价日期": "2026-09-17",
|
|
}
|
|
)
|
|
self.assertIn("通关口岸(非必填):", text)
|
|
|
|
def test_hk_shows_load(self):
|
|
text = copy.land_confirm_card(
|
|
{
|
|
"运输类型": "中港",
|
|
"线路类别": "东南亚",
|
|
"运输分类": "急件",
|
|
"中港装载方式": "零担/集拼",
|
|
"起运港": "广州",
|
|
"目的港": "香港",
|
|
"品名": "衣服",
|
|
"车型/数量": "9米6/1",
|
|
"报价日期": "2026-09-17",
|
|
}
|
|
)
|
|
self.assertIn("零担/集拼", text)
|
|
self.assertIn("车型/数量(必填):9米6/1", text)
|
|
self.assertNotIn("\n数量(必填)", text)
|
|
|
|
def test_hk_full_truck_hides_vehicle(self):
|
|
text = copy.land_confirm_card(
|
|
{
|
|
"运输类型": "中港",
|
|
"线路类别": "东南亚",
|
|
"运输分类": "急件",
|
|
"中港装载方式": "整车",
|
|
"起运港": "广州",
|
|
"目的港": "香港",
|
|
"品名": "衣服",
|
|
"报价日期": "2026-09-17",
|
|
}
|
|
)
|
|
self.assertIn("整车", text)
|
|
self.assertNotIn("车型/数量", text)
|
|
|
|
def test_domestic_ftl_one_field(self):
|
|
text = copy.land_confirm_card(
|
|
{
|
|
"运输类型": "国内运输整车",
|
|
"线路类别": "国内长途/零担",
|
|
"运输分类": "急件",
|
|
"起运港": "广州",
|
|
"目的港": "深圳",
|
|
"品名": "衣服",
|
|
"车型/数量": "9米6/1",
|
|
"报价日期": "2026-09-17",
|
|
}
|
|
)
|
|
self.assertIn("车型/数量(必填):9米6/1", text)
|
|
self.assertNotIn("\n数量(必填)", text)
|
|
|
|
def test_no_staff_copy(self):
|
|
self.assertIn("陆运产品岗", copy.land_group_no_staff())
|
|
|
|
def test_inquiry_card_lists_land_fields_and_wo(self):
|
|
text = copy.inquiry_card(
|
|
work_order_no="WO202609170006",
|
|
facts={
|
|
"运输类型": "国内运输拼车",
|
|
"线路类别": "国内长途/零担",
|
|
"运输分类": "急件",
|
|
"起运港": "广州",
|
|
"目的港": "深圳",
|
|
"品名": "衣服",
|
|
"体积": "100CBM",
|
|
"毛重": "50kg",
|
|
"报价日期": "2026-09-17",
|
|
},
|
|
transport_mode="陆运",
|
|
)
|
|
self.assertIn("工单号:WO202609170006", text)
|
|
self.assertIn("运输方式:陆运", text)
|
|
self.assertIn("运输类型:国内运输拼车", text)
|
|
self.assertIn("始发站:广州", text)
|
|
self.assertIn("货物品名:衣服", text)
|
|
self.assertIn("工单已创建,正在查询TMS报价。", text)
|
|
self.assertNotIn("件数", text)
|
|
|
|
def test_scheme_card_uses_land_fields_not_sea(self):
|
|
facts = {
|
|
"运输类型": "国内运输拼车",
|
|
"线路类别": "国内城配/拖车/打包",
|
|
"运输分类": "普件,常用线路/常规车型",
|
|
"起运港": "泉州市",
|
|
"目的港": "南京市",
|
|
"品名": "通信机柜及线缆配件",
|
|
"体积": "10CBM",
|
|
"毛重": "10KG",
|
|
"报价日期": "2026-09-17",
|
|
}
|
|
quote = {"total": "CNY 1200", "eta": "3天", "valid_until": "2026-09-20"}
|
|
text = copy.scheme_card(
|
|
work_order_no="WO202609170011",
|
|
status="已报价",
|
|
facts=facts,
|
|
quote=quote,
|
|
transport_mode="陆运",
|
|
)
|
|
self.assertIn("运输方式:陆运", text)
|
|
self.assertIn("运输类型:国内运输拼车", text)
|
|
self.assertIn("始发站:泉州市", text)
|
|
self.assertIn("货物品名:通信机柜及线缆配件", text)
|
|
self.assertIn("体积:10CBM", text)
|
|
self.assertNotIn("整柜或拼柜", text)
|
|
self.assertNotIn("箱型箱量", text)
|
|
self.assertNotIn("件数:", text)
|
|
self.assertNotIn("包装类型:", text)
|
|
rows = {
|
|
x["keyname"]: x["value"]
|
|
for x in copy.scheme_horizontal_rows(
|
|
work_order_no="WO202609170011",
|
|
facts=facts,
|
|
quote=quote,
|
|
transport_mode="陆运",
|
|
)
|
|
}
|
|
self.assertIn("陆运 泉州市→南京市", rows["线路"])
|
|
self.assertIn("国内运输拼车", rows["类型"])
|
|
self.assertIn("国内城配/拖车/打包", rows["类型"])
|
|
self.assertIn("通信机柜及线缆配件", rows["货物"])
|
|
self.assertIn("10CBM", rows["货物"])
|
|
self.assertNotIn("航线", rows)
|
|
self.assertNotIn("箱型", rows)
|
|
self.assertNotIn("包装", rows)
|
|
self.assertNotIn("空运", "".join(rows.values()))
|
|
self.assertNotIn("海运", "".join(rows.values()))
|
|
|
|
def test_scheme_card_ftl_shows_vehicle_combo(self):
|
|
facts = {
|
|
"运输类型": "国内运输整车",
|
|
"线路类别": "国内长途/零担",
|
|
"运输分类": "急件",
|
|
"起运港": "广州",
|
|
"目的港": "深圳",
|
|
"品名": "衣服",
|
|
"车型/数量": "9米6/1",
|
|
}
|
|
rows = {
|
|
x["keyname"]: x["value"]
|
|
for x in copy.scheme_horizontal_rows(
|
|
work_order_no="WO202609170012",
|
|
facts=facts,
|
|
quote={},
|
|
transport_mode="陆运",
|
|
)
|
|
}
|
|
self.assertIn("9米6/1", rows["货物"])
|
|
self.assertNotIn("CBM", rows["货物"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|