落地陆运群内协同:按填写样例拉群并只列本单协同项,进群把私聊已抽到的字段带上。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
陆运选项联动单测:类型/线路/分类/中港装载,选错只纠正该项。
|
||||
陆运选项单测:三项各自必填、不联动;中港拆进运输类型;样例表跟类型/线路缺项走。
|
||||
|
||||
不连企微、主账、TMS。
|
||||
"""
|
||||
@@ -18,12 +18,14 @@ from agent.schema.land_options import (
|
||||
harvest_land_options,
|
||||
looks_like_confirm,
|
||||
option_prompt,
|
||||
option_prompt_needs_sample,
|
||||
sample_pair_allowed,
|
||||
validate_land_options,
|
||||
)
|
||||
|
||||
|
||||
class LandOptionsTest(unittest.TestCase):
|
||||
def test_domestic_ltl_rejects_sea_route(self):
|
||||
def test_any_type_route_combo_ok(self):
|
||||
got = validate_land_options(
|
||||
{
|
||||
"运输类型": "国内运输拼车",
|
||||
@@ -31,28 +33,70 @@ class LandOptionsTest(unittest.TestCase):
|
||||
"运输分类": "急件",
|
||||
}
|
||||
)
|
||||
self.assertFalse(got["ok"])
|
||||
msg = got["errors"][0]["message"]
|
||||
self.assertIn("国内长途/零担", msg)
|
||||
self.assertIn("国内城配/拖车/打包", msg)
|
||||
self.assertTrue(got["ok"])
|
||||
self.assertEqual(got["normalized"]["运输类型"], "国内运输拼车")
|
||||
self.assertEqual(got["normalized"]["线路类别"], "东南亚")
|
||||
|
||||
def test_bare_hk_does_not_fill_type_or_route(self):
|
||||
cur = harvest_land_options("中港 急件")
|
||||
self.assertFalse(cur.get("运输类型"))
|
||||
self.assertFalse(cur.get("线路类别"))
|
||||
self.assertEqual(cur.get("运输分类"), "急件")
|
||||
|
||||
def test_hk_full_and_lcl_types(self):
|
||||
self.assertEqual(
|
||||
harvest_land_options("中港整车")["运输类型"], "中港整车"
|
||||
)
|
||||
self.assertEqual(
|
||||
harvest_land_options("中港零担/集拼 东南亚")["运输类型"],
|
||||
"中港零担/集拼",
|
||||
)
|
||||
self.assertEqual(
|
||||
harvest_land_options("中港零担")["运输类型"], "中港零担/集拼"
|
||||
)
|
||||
|
||||
def test_new_class_names(self):
|
||||
cur = harvest_land_options(
|
||||
"普件(东南亚、中港常用线路/常规车型)"
|
||||
)
|
||||
self.assertEqual(
|
||||
cur["运输分类"], "普件(东南亚、中港常用线路/常规车型)"
|
||||
)
|
||||
self.assertFalse(
|
||||
harvest_land_options("普件,常用线路/常规车型").get("运输分类")
|
||||
)
|
||||
|
||||
def test_no_hk_load_field(self):
|
||||
got = validate_land_options(
|
||||
{
|
||||
"运输类型": "中港整车",
|
||||
"线路类别": "东南亚",
|
||||
"运输分类": "急件",
|
||||
}
|
||||
)
|
||||
self.assertTrue(got["ok"])
|
||||
self.assertNotIn("中港装载方式", got["missing"])
|
||||
self.assertFalse(got["normalized"].get("中港装载方式"))
|
||||
|
||||
def test_followup_route_class_keeps_type(self):
|
||||
cur = harvest_land_options(
|
||||
"国内城配/拖车/打包;普件,常用线路/常规车型",
|
||||
"国内城配/拖车/打包;普件(东南亚、中港常用线路/常规车型)",
|
||||
current={"运输类型": "国内运输拼车"},
|
||||
)
|
||||
self.assertEqual(cur["运输类型"], "国内运输拼车")
|
||||
self.assertEqual(cur["线路类别"], "国内城配/拖车/打包")
|
||||
self.assertEqual(cur["运输分类"], "普件,常用线路/常规车型")
|
||||
self.assertEqual(
|
||||
cur["运输分类"], "普件(东南亚、中港常用线路/常规车型)"
|
||||
)
|
||||
|
||||
def test_model_land_does_not_wipe_type(self):
|
||||
dropped = harvest_land_options(
|
||||
"国内城配/拖车/打包;普件,常用线路/常规车型",
|
||||
"国内城配/拖车/打包;急件",
|
||||
current={"运输类型": "陆运"},
|
||||
)
|
||||
self.assertFalse(dropped.get("运输类型"))
|
||||
cur = harvest_land_options(
|
||||
"国内城配/拖车/打包;普件,常用线路/常规车型",
|
||||
"国内城配/拖车/打包;急件",
|
||||
current={"运输类型": "国内运输拼车"},
|
||||
)
|
||||
junk = harvest_land_options("陆运", current=cur)
|
||||
@@ -64,36 +108,66 @@ class LandOptionsTest(unittest.TestCase):
|
||||
|
||||
def test_full_prompt_when_empty(self):
|
||||
text = option_prompt(current={})
|
||||
self.assertIn("运输类型", text)
|
||||
self.assertIn("线路类别", text)
|
||||
self.assertIn("运输分类", text)
|
||||
self.assertIn("国内运输拼车", text)
|
||||
self.assertIn("整车", text)
|
||||
self.assertNotIn("请补充陆运类型:", text)
|
||||
self.assertIn("请一次选择:运输类型、线路类别、运输分类", text)
|
||||
self.assertIn("运输类型(必填):可选择回复,", text)
|
||||
self.assertIn("中港整车", text)
|
||||
self.assertIn("中港零担/集拼", text)
|
||||
self.assertIn("线路类别(必填):可选择回复,", text)
|
||||
self.assertIn("国内长途/零担", text)
|
||||
self.assertIn("1.普件(东南亚、中港常用线路/常规车型)", text)
|
||||
self.assertIn("填写样例见图", text)
|
||||
self.assertNotIn("国内运输整车 + 国内城配/拖车/打包", text)
|
||||
self.assertNotIn("┌", text)
|
||||
self.assertNotIn("| 国内运输整车 |", text)
|
||||
self.assertNotIn("仅供参考", text)
|
||||
self.assertNotIn("中港装载方式", text)
|
||||
self.assertNotIn("跟运输类型联动", text)
|
||||
|
||||
def test_copy_alias_lists_all_three(self):
|
||||
def test_copy_alias_lists_new_types(self):
|
||||
from agent.policy import inquiry_copy as copy
|
||||
|
||||
text = copy.ASK_LAND_SUBTYPE
|
||||
self.assertIn("运输类型", text)
|
||||
self.assertIn("线路类别", text)
|
||||
self.assertIn("运输分类", text)
|
||||
self.assertIn("中港整车", text)
|
||||
self.assertIn("填写样例", text)
|
||||
self.assertNotIn("请补充陆运类型:国内运输拼车", text)
|
||||
|
||||
def test_narrow_prompt_when_type_known(self):
|
||||
def test_sample_table_when_route_missing(self):
|
||||
text = option_prompt(current={"运输类型": "国内运输拼车"})
|
||||
self.assertIn("国内长途/零担", text)
|
||||
self.assertNotIn("请选择运输类型", text)
|
||||
self.assertIn("线路类别(必填)", text)
|
||||
self.assertIn("填写样例见图", text)
|
||||
self.assertTrue(option_prompt_needs_sample(current={"运输类型": "国内运输拼车"}))
|
||||
self.assertNotIn("国内运输拼车 + 国内长途/零担", text)
|
||||
self.assertNotIn("请一次选择:运输类型", text)
|
||||
self.assertNotIn("运输类型(必填)", text)
|
||||
|
||||
def test_hk_needs_load(self):
|
||||
got = validate_land_options(
|
||||
{
|
||||
"运输类型": "中港",
|
||||
def test_sample_pairs_go_to_image_not_text(self):
|
||||
from agent.policy import inquiry_copy as copy
|
||||
|
||||
text = option_prompt(current={})
|
||||
self.assertIn("填写样例见图", text)
|
||||
self.assertNotIn("国内运输拼车 + 国内长途/零担", text)
|
||||
extra = copy.land_sample_image_payload()
|
||||
self.assertEqual(extra.get("msgtype"), "image")
|
||||
self.assertTrue(os.path.isfile(str(extra.get("filepath") or "")))
|
||||
self.assertGreater(os.path.getsize(str(extra["filepath"])), 1000)
|
||||
|
||||
def test_no_sample_when_only_class_missing(self):
|
||||
text = option_prompt(
|
||||
current={
|
||||
"运输类型": "国内运输拼车",
|
||||
"线路类别": "东南亚",
|
||||
"运输分类": "急件",
|
||||
}
|
||||
)
|
||||
self.assertIn("中港装载方式", got["missing"])
|
||||
self.assertIn("运输分类(必填)", text)
|
||||
self.assertNotIn("填写样例", text)
|
||||
|
||||
def test_sample_pair_gate(self):
|
||||
self.assertTrue(sample_pair_allowed("国内运输拼车", "国内长途/零担"))
|
||||
self.assertTrue(sample_pair_allowed("国内运输整车", "国内城配/拖车/打包"))
|
||||
self.assertTrue(sample_pair_allowed("国内运输整车", "国内长途/零担"))
|
||||
self.assertTrue(sample_pair_allowed("中港整车", "中港/中亚/中欧"))
|
||||
self.assertFalse(sample_pair_allowed("国内运输拼车", "东南亚"))
|
||||
self.assertFalse(sample_pair_allowed("中港整车", "东南亚"))
|
||||
|
||||
def test_confirm_intent(self):
|
||||
self.assertTrue(looks_like_confirm("确认"))
|
||||
|
||||
Reference in New Issue
Block a user