Files
syops/backend/tests/test_shipping_notice_match_summary.py
T

42 lines
1.2 KiB
Python

from app.services.shipping_notice.match import format_match_summary
def test_format_match_summary_fulfillable():
msg = format_match_summary(
"fulfillable",
[
{
"part_number": "D4-A08AR12000002",
"reservation_id": "AWS-311",
"required_qty": 2,
"available_qty": 5,
"shortage_qty": 0,
"line_status": "ok",
}
],
)
assert "【库存匹配结果】" in msg or "匹配明细" in msg
assert "| # | 预订单号 | 内部料号 |" in msg
assert "| 1 | AWS-311 | D4-A08AR12000002 | 2 | 5 | - |" in msg
assert "✅ 充足" in msg
assert "可生成发货 Excel" in msg
def test_format_match_summary_shortage():
msg = format_match_summary(
"partial",
[
{
"part_number": "A001",
"reservation_id": "R-1",
"required_qty": 100,
"available_qty": 5,
"shortage_qty": 95,
"line_status": "partial",
}
],
)
assert "| R-1 | A001 | 100 | 5 | 95 |" in msg
assert "⚠️ 部分满足" in msg
assert "存在库存缺口" in msg