空运未填报价日期时不默认当天,查出舱位后由销售点选再写回日期。

包装类型里的托盘不再被抄进增值服务。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-13 18:35:52 +08:00
co-authored by Cursor
parent dda210c219
commit 7ef4a1b1cf
21 changed files with 1068 additions and 58 deletions
@@ -87,6 +87,7 @@ class AirRouteOptionsTests(unittest.TestCase):
"毛重": "100",
"体积": "2",
"包装方式": "托盘",
"报价日期": "2026-09-16",
"tms_multi": "1",
}
phase = flow.on_text(
@@ -144,6 +145,7 @@ class AirRouteOptionsTests(unittest.TestCase):
"毛重": "21",
"体积": "1",
"包装方式": "散货",
"报价日期": "2026-09-16",
}
self.assertEqual(
flow.on_text(sender_id="u_hgh", text="空运", reply=reply, injected_facts=facts, injected_mode="AIR"),
@@ -174,6 +176,7 @@ class AirRouteOptionsTests(unittest.TestCase):
"毛重": "100",
"体积": "2",
"包装方式": "托盘",
"报价日期": "2026-09-16",
"tms_multi": "1",
}
flow.on_text(sender_id="u_zuh", text="空运", reply=reply, injected_facts=facts, injected_mode="AIR")
@@ -199,6 +202,7 @@ class AirRouteOptionsTests(unittest.TestCase):
"毛重": "100",
"体积": "2",
"包装方式": "托盘",
"报价日期": "2026-09-16",
"tms_multi": "1",
}
phase = flow.on_text(
@@ -413,6 +417,118 @@ class AirRouteOptionsTests(unittest.TestCase):
self.assertIn("window.close()", desktop)
self.assertNotIn("closeWindow", dead)
def test_blank_date_always_opens_cabin_page_and_writes_flight_date(self) -> None:
"""没填日期:1 条舱位也要进 H5;选定后用该条总价,航班日期写回,不再查价。"""
from agent.schema.air_route_options import sort_cabin_options
later = {
"originAirportCode": "PVG",
"destinationAirportCode": "LAX",
"flightDate": "2026-10-21",
"schedule": "D1",
"airlineName": "东航",
"salePrice": 1000,
"currency": "CNY",
}
earlier = {
"originAirportCode": "PVG",
"destinationAirportCode": "LAX",
"flightDate": "2026-10-20",
"schedule": "D234567",
"airlineName": "南航",
"salePrice": 3200,
"currency": "CNY",
}
ordered = sort_cabin_options([later, earlier])
self.assertEqual(option_flight_date_of(ordered[0]), "2026-10-20")
class Ledger(MemoryLedger):
def __init__(self) -> None:
super().__init__()
self.queries = 0
def query_tms(self, **kwargs):
self.queries += 1
out = super().query_tms(**kwargs)
out["quote"]["airOptions"] = [later, earlier]
return out
ledger = Ledger()
flow = AirTextInquiryFlow(ledger)
replies: list[str] = []
def reply(text: str, extra=None) -> None:
replies.append(text)
_ = extra
facts = {
"起运港": "上海",
"目的港": "洛杉矶",
"品名": "普货",
"件数": "3",
"毛重": "180",
"体积": "2.5",
"包装方式": "纸箱",
}
self.assertEqual(
flow.on_text(sender_id="u_cabin", text="空运", reply=reply, injected_facts=facts, injected_mode="AIR"),
"wait_confirm",
)
self.assertIn("报价日期(非必填):", replies[-1])
self.assertNotIn("报价日期:2026", replies[-1])
self.assertEqual(flow.on_text(sender_id="u_cabin", text="确定", reply=reply), "wait_air_route")
self.assertEqual(ledger.queries, 1)
self.assertTrue(any("条舱位" in x for x in replies))
self.assertFalse(any("条线路" in x for x in replies))
self.assertEqual(flow.select_air_route(sender_id="u_cabin", index=0, reply=reply), "wait_collab")
self.assertEqual(ledger.queries, 1)
sess = flow.session_of("u_cabin")
self.assertEqual(sess.facts.get("报价日期"), "2026-10-20")
self.assertIn("3200", str(sess.quote.get("total")))
def test_cabin_page_shows_six_fields_and_total_only(self) -> None:
html = render_air_route_page(
{
"cabin_pick": True,
"work_order_no": "WO202610130001",
"facts": {},
"quote": {
"airOptions": [
{
"originAirportCode": "PVG",
"destinationAirportCode": "LAX",
"flightDate": "2026-10-20",
"schedule": "D234567",
"airlineName": "南航",
"salePrice": 3200,
"currency": "CNY",
"departureCharges": [
{"chargeName": "运输费", "currency": "CNY", "unitPrice": 11}
],
}
]
},
}
)
self.assertIn("选择舱位", html)
self.assertIn("起运地", html)
self.assertIn("目的地", html)
self.assertIn("航班日期", html)
self.assertIn("2026-10-20", html)
self.assertIn("班期", html)
self.assertIn("D234567", html)
self.assertIn("航司", html)
self.assertIn("南航", html)
self.assertIn("3200", html)
self.assertNotIn("运输费", html)
self.assertNotIn("userid", html.lower())
def option_flight_date_of(option: dict) -> str:
from agent.schema.air_route_options import option_flight_date
return option_flight_date(option)
if __name__ == "__main__":
unittest.main()