feat(shipping-notice): 添加识别定义和规则集管理功能,支持客户和站点的可配置识别规则
This commit is contained in:
1 parent
88408490d7
commit
34d489a2d1
167 files changed
+10365
-7978
No files matched your search
@@ -9,6 +9,7 @@ from app.services.shipping_notice.query_service import (
|
||||
get_task_by_ref,
|
||||
get_task_in_batch,
|
||||
list_tasks_for_user,
|
||||
list_tasks_page_for_user,
|
||||
list_batch_task_summaries,
|
||||
resolve_task_from_payload,
|
||||
serialize_batch,
|
||||
@@ -108,6 +109,53 @@ def test_list_tasks_for_user_filters_shortage_review_by_user_facing_state(app):
|
||||
assert [item["task_no"] for item in rows] == ["SN-FILTER-SHORTAGE"]
|
||||
|
||||
|
||||
def test_list_tasks_page_for_user_returns_stable_page_and_total(app):
|
||||
"""分页必须由数据库排序、计数后切片,不能把固定上限结果伪装成分页。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
|
||||
db.session.add_all([
|
||||
ShippingTask(task_no=f"SN-PAGE-{index:02d}", process_status="created", source_type="manual")
|
||||
for index in range(1, 6)
|
||||
])
|
||||
db.session.commit()
|
||||
|
||||
first_page = list_tasks_page_for_user(999999, page=1, page_size=2)
|
||||
second_page = list_tasks_page_for_user(999999, page=2, page_size=2)
|
||||
|
||||
# 关键断言:总数独立于每页大小,页面之间不重叠且均不超过 page_size。
|
||||
assert first_page["total"] == 5
|
||||
assert first_page["page"] == 1
|
||||
assert len(first_page["items"]) == 2
|
||||
assert second_page["total"] == 5
|
||||
assert second_page["page"] == 2
|
||||
assert len(second_page["items"]) == 2
|
||||
assert {item["task_no"] for item in first_page["items"]}.isdisjoint(
|
||||
{item["task_no"] for item in second_page["items"]}
|
||||
)
|
||||
|
||||
|
||||
def test_list_tasks_page_for_user_applies_status_filter_before_count(app):
|
||||
"""分页总数必须只统计当前状态筛选命中的任务。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
|
||||
db.session.add_all([
|
||||
ShippingTask(task_no="SN-PAGE-FILTER-1", process_status="created", source_type="manual"),
|
||||
ShippingTask(task_no="SN-PAGE-FILTER-2", process_status="created", source_type="manual"),
|
||||
ShippingTask(task_no="SN-PAGE-FILTER-3", process_status="uploaded", source_type="manual"),
|
||||
])
|
||||
db.session.commit()
|
||||
|
||||
result = list_tasks_page_for_user(999999, process_status="created", page=1, page_size=10)
|
||||
|
||||
# 关键断言:uploaded 任务既不在 items 中,也不计入总数。
|
||||
assert result["total"] == 2
|
||||
assert {item["task_no"] for item in result["items"]} == {
|
||||
"SN-PAGE-FILTER-1", "SN-PAGE-FILTER-2",
|
||||
}
|
||||
|
||||
|
||||
def test_task_export_error_message_distinct_for_missing_path(app):
|
||||
"""无导出路径与磁盘缺失应返回不同错误文案。"""
|
||||
with app.app_context():
|
||||
@@ -139,8 +187,8 @@ def test_task_projection_tool_strips_internal_fields(app):
|
||||
)
|
||||
data = serialize_task(task, TaskProjection.TOOL)
|
||||
assert data["task_no"] == "SN-PROJ-TOOL"
|
||||
assert data["customer_name"] == "ACME"
|
||||
assert data["lines"] == [{"sku": "A001"}]
|
||||
assert data["customer_name"] is None
|
||||
assert data["lines"] == []
|
||||
assert not TOOL_TASK_DATA_OMIT.intersection(data.keys())
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user