43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
from __future__ import annotations
|
||
|
||
from datetime import date
|
||
|
||
from app.services.application_fact_resolver import (
|
||
ApplicationFactResolver,
|
||
resolve_application_facts,
|
||
)
|
||
|
||
|
||
def test_application_fact_resolver_extracts_travel_application_fields() -> None:
|
||
facts = resolve_application_facts(
|
||
"明天去上海出差3天,辅助国网仿生产环境部署,高铁往返",
|
||
"expense_application",
|
||
date(2026, 6, 23),
|
||
)
|
||
|
||
assert facts["expense_type"] == "travel"
|
||
assert facts["time_range"] == "2026-06-24"
|
||
assert facts["location"] == "上海"
|
||
assert facts["reason"] == "辅助国网仿生产环境部署,高铁往返"
|
||
assert facts["transport_mode"] == "train"
|
||
|
||
|
||
def test_application_fact_resolver_preserves_reimbursement_transport_semantics() -> None:
|
||
facts = resolve_application_facts(
|
||
"报销昨天去北京客户现场沟通产生的出租车费用",
|
||
"reimbursement",
|
||
date(2026, 6, 23),
|
||
)
|
||
|
||
assert facts["expense_type"] == "transport"
|
||
assert facts["time_range"] == "2026-06-22"
|
||
assert facts["location"] == "北京"
|
||
assert facts["reason"] == "去北京客户现场沟通产生的出租车费用"
|
||
assert facts["transport_mode"] == "taxi"
|
||
|
||
|
||
def test_application_fact_resolver_keeps_static_wrapper_api() -> None:
|
||
assert ApplicationFactResolver.infer_expense_type("打车去客户现场", "expense_application") == "travel"
|
||
assert ApplicationFactResolver.infer_expense_type("打车去客户现场", "reimbursement") == "transport"
|
||
assert ApplicationFactResolver.extract_time_range("2026-07-01 去深圳", date(2026, 6, 23)) == "2026-07-01"
|