Files
inquiry_robot/inquiry-agent/tests/test_memory_land_staff.py

45 lines
1.4 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)
os.environ.setdefault("YTD_ENV", "test")
os.environ.setdefault("LEDGER_BACKEND", "memory")
from agent.ledger.memory_ledger import MemoryLedger
class MemoryLandStaffTest(unittest.TestCase):
def test_match_route_token(self):
book = MemoryLedger()
book.set_land_staff(
[
{"roleCode": "land", "status": "active", "wecomId": "a", "name": "甲", "routes": "东南亚"},
{"roleCode": "land", "status": "active", "wecomId": "b", "name": "乙", "routes": "国内长途/零担"},
{"roleCode": "land", "status": "active", "wecomId": "c", "name": "丙", "routes": "中港/中亚/中欧,东南亚"},
]
)
hits = book.match_land_staff(route_category="东南亚")
names = [x.get("name") for x in hits]
self.assertEqual(names, ["甲", "丙"])
def test_sea_staff_not_pulled(self):
book = MemoryLedger()
book.set_land_staff(
[{"roleCode": "sea", "status": "active", "wecomId": "s", "name": "海", "routes": "东南亚"}]
)
self.assertEqual(book.match_land_staff(route_category="东南亚"), [])
if __name__ == "__main__":
unittest.main()