点名海运时丢掉旧陆运补问草稿,避免补字段误发填写样例图。 Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
"""
|
||
海运运输分类:只认 Port to Port、其他。
|
||
"""
|
||
|
||
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.schema.sea_options import (
|
||
canonicalize_sea_class,
|
||
drop_invented_door_trade_terms,
|
||
harvest_sea_class,
|
||
sea_class_prompt,
|
||
)
|
||
|
||
|
||
class SeaOptionsTest(unittest.TestCase):
|
||
def test_port_to_port_aliases(self):
|
||
self.assertEqual(canonicalize_sea_class("Port to Port"), "Port to Port")
|
||
self.assertEqual(canonicalize_sea_class("port to port"), "Port to Port")
|
||
self.assertEqual(canonicalize_sea_class("P2P"), "Port to Port")
|
||
self.assertEqual(canonicalize_sea_class("港到港"), "Port to Port")
|
||
|
||
def test_other_alias(self):
|
||
self.assertEqual(canonicalize_sea_class("其他"), "其他")
|
||
self.assertEqual(canonicalize_sea_class("其它"), "其他")
|
||
|
||
def test_door_to_door_rejected(self):
|
||
self.assertEqual(canonicalize_sea_class("门到门"), "")
|
||
|
||
def test_harvest_keeps_current_when_text_has_none(self):
|
||
got = harvest_sea_class("上海到洛杉矶整柜", {"运输分类": "Port to Port"})
|
||
self.assertEqual(got["运输分类"], "Port to Port")
|
||
|
||
def test_harvest_overrides_from_text(self):
|
||
got = harvest_sea_class("运输分类:其他", {"运输分类": "Port to Port"})
|
||
self.assertEqual(got["运输分类"], "其他")
|
||
|
||
def test_door_to_door_not_kept_as_trade_terms(self):
|
||
text = "海运、纽约港到巴生西港,机器设备,40HQ*1,整柜,1.5KG,15CBM,15件"
|
||
got = drop_invented_door_trade_terms(text, {"贸易条款": "门到门", "品名": "机器设备"})
|
||
self.assertNotIn("贸易条款", got)
|
||
kept = drop_invented_door_trade_terms("贸易条款:门到门", {"贸易条款": "门到门"})
|
||
self.assertEqual(kept["贸易条款"], "门到门")
|
||
|
||
def test_prompt_lists_two_options_only(self):
|
||
text = sea_class_prompt()
|
||
self.assertIn("Port to Port", text)
|
||
self.assertIn("其他", text)
|
||
self.assertNotIn("门到门", text)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
unittest.main()
|