feat: 海运运输分类只认 Port to Port 与其他
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
海运运输分类:只认 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,
|
||||
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_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()
|
||||
Reference in New Issue
Block a user