55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
"""运输计划按段现场回传校验"""
|
|
import pytest
|
|
|
|
from app.services.pl_transport_stop_feedback_service import (
|
|
_dump_product_feedbacks,
|
|
_parse_product_feedbacks,
|
|
save_site_stop_feedback,
|
|
)
|
|
|
|
|
|
def test_parse_and_dump_driver_stop_product_feedbacks():
|
|
raw = _dump_product_feedbacks(
|
|
[
|
|
{
|
|
"stopProductId": "sp1",
|
|
"actualQty": 12.5,
|
|
"brandQtys": [{"brandId": "b1", "brandName": "品牌A", "qty": 12.5}],
|
|
}
|
|
]
|
|
)
|
|
parsed = _parse_product_feedbacks(raw)
|
|
assert "sp1" in parsed
|
|
assert parsed["sp1"]["actualQty"] == 12.5
|
|
assert parsed["sp1"]["brandQtys"][0]["brandName"] == "品牌A"
|
|
|
|
|
|
def test_save_site_stop_feedback_requires_quantity_before_attachments():
|
|
with pytest.raises(ValueError, match="请先填写数量"):
|
|
save_site_stop_feedback(
|
|
db=None, # type: ignore[arg-type]
|
|
tenant_no="t1",
|
|
transport_id="tr1",
|
|
plan_id="p1",
|
|
stop_type="load",
|
|
stop_id="s1",
|
|
business_type="出库",
|
|
quantity=None,
|
|
attachment_urls=["a.jpg"],
|
|
)
|
|
|
|
|
|
def test_save_site_stop_feedback_requires_product_qty_before_attachments():
|
|
with pytest.raises(ValueError, match="请先填写数量"):
|
|
save_site_stop_feedback(
|
|
db=None, # type: ignore[arg-type]
|
|
tenant_no="t1",
|
|
transport_id="tr1",
|
|
plan_id="p1",
|
|
stop_type="load",
|
|
stop_id="s1",
|
|
business_type="出库",
|
|
products=[{"stopProductId": "sp1", "actualQty": 0}],
|
|
attachment_urls=["a.jpg"],
|
|
)
|