feat: 海运询价必填加上贸易条款和运输分类
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -29,7 +29,7 @@ from agent.handlers.text_inquiry import handle_text_inquiry
|
||||
from agent.ledger.memory_ledger import MemoryLedger
|
||||
from agent.policy import inquiry_copy as copy
|
||||
from agent.policy.sea_text_flow import SeaTextInquiryFlow, reset_sea_text_flow_for_test
|
||||
from agent.schema.field_validate import validate_required_fields
|
||||
from agent.schema.field_validate import SEA_COLLAB_FIELDS, validate_required_fields
|
||||
from agent.schema.tms_sea_query import assemble_sea_query
|
||||
|
||||
|
||||
@@ -43,6 +43,15 @@ COMPLETE_SEA = {
|
||||
}
|
||||
|
||||
|
||||
class SeaCollabContractTests(unittest.TestCase):
|
||||
def test_collab_no_longer_asks_trade_terms(self):
|
||||
self.assertNotIn("贸易条款", SEA_COLLAB_FIELDS)
|
||||
self.assertEqual(
|
||||
SEA_COLLAB_FIELDS,
|
||||
("货好时间", "HS编码", "是否含油", "是否含电", "是否含磁"),
|
||||
)
|
||||
|
||||
|
||||
class FakeGroupClient:
|
||||
"""单测假企微建群:不打外网。"""
|
||||
|
||||
@@ -123,6 +132,8 @@ class SeaTextInquiryTests(unittest.TestCase):
|
||||
"件数": "15件",
|
||||
"整柜或拼柜": "整柜",
|
||||
"箱型箱量": "1x40HQ",
|
||||
"贸易条款": "FOB",
|
||||
"运输分类": "Port to Port",
|
||||
}
|
||||
check = validate_required_fields(facts=facts, business_line="SEA")
|
||||
self.assertTrue(check["ok"])
|
||||
@@ -136,6 +147,8 @@ class SeaTextInquiryTests(unittest.TestCase):
|
||||
"品名": "茶叶",
|
||||
"货量": "20吨",
|
||||
"整柜或拼柜": "整柜",
|
||||
"贸易条款": "FOB",
|
||||
"运输分类": "Port to Port",
|
||||
}
|
||||
check = validate_required_fields(facts=facts, business_line="SEA")
|
||||
self.assertFalse(check["ok"])
|
||||
@@ -157,6 +170,52 @@ class SeaTextInquiryTests(unittest.TestCase):
|
||||
self.assertNotIn("报价日期:(如", text)
|
||||
self.assertIn("报价日期:", text)
|
||||
|
||||
def test_sea_requires_trade_terms_and_class(self) -> None:
|
||||
facts = {
|
||||
"起运港": "上海",
|
||||
"目的港": "洛杉矶",
|
||||
"品名": "普货",
|
||||
"货量": "20吨",
|
||||
"整柜或拼柜": "整柜",
|
||||
"箱型箱量": "1x40HQ",
|
||||
}
|
||||
check = validate_required_fields(facts=facts, business_line="SEA")
|
||||
self.assertFalse(check["ok"])
|
||||
self.assertIn("贸易条款", check["missing"])
|
||||
self.assertIn("运输分类", check["missing"])
|
||||
self.assertIn("贸易条款", check["missing_display"])
|
||||
self.assertIn("运输分类", check["missing_display"])
|
||||
|
||||
def test_sea_rejects_door_to_door_class(self) -> None:
|
||||
facts = {
|
||||
"起运港": "上海",
|
||||
"目的港": "洛杉矶",
|
||||
"品名": "普货",
|
||||
"货量": "20吨",
|
||||
"整柜或拼柜": "整柜",
|
||||
"箱型箱量": "1x40HQ",
|
||||
"贸易条款": "FOB",
|
||||
"运输分类": "门到门",
|
||||
}
|
||||
check = validate_required_fields(facts=facts, business_line="SEA")
|
||||
self.assertFalse(check["ok"])
|
||||
self.assertIn("运输分类", check["missing"])
|
||||
|
||||
def test_sea_canonicalizes_p2p(self) -> None:
|
||||
facts = {
|
||||
"起运港": "上海",
|
||||
"目的港": "洛杉矶",
|
||||
"品名": "普货",
|
||||
"货量": "20吨",
|
||||
"整柜或拼柜": "整柜",
|
||||
"箱型箱量": "1x40HQ",
|
||||
"贸易条款": "到岸",
|
||||
"运输分类": "p2p",
|
||||
}
|
||||
check = validate_required_fields(facts=facts, business_line="SEA")
|
||||
self.assertTrue(check["ok"])
|
||||
self.assertEqual(check["facts"]["运输分类"], "Port to Port")
|
||||
|
||||
def test_complete_sea_inquiry_card_uses_seven_fields(self) -> None:
|
||||
phase = self.flow.on_text(
|
||||
sender_id="s1",
|
||||
|
||||
Reference in New Issue
Block a user