- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。 - 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。 - 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。 - 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。 - 增强文档与代码注释,反映新的业务逻辑与功能要求。
75 lines
2.9 KiB
Python
75 lines
2.9 KiB
Python
"""
|
|
tests/test_shipping_stp_progress_nodes.py
|
|
|
|
用途:验收阶段 4 固定 progress_nodes 投影——顺序、状态映射、货代节点非自动 RPA。
|
|
依赖:stp_progress_contract、types.SimpleNamespace。
|
|
逻辑:构造 Task 替身;断言节点码顺序与 WorkflowNodeStatus;禁止前端百分比语义。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from types import SimpleNamespace
|
|
|
|
from app.services.shipping_notice.stp_progress_contract import (
|
|
STP_PROGRESS_NODE_DEFS,
|
|
derive_overall_node_status,
|
|
project_task_progress_nodes,
|
|
)
|
|
|
|
|
|
def test_progress_nodes_follow_fixed_order_and_manual_freight():
|
|
"""Excel 就绪后货代节点为 manual_takeover,不得投影为 running(首期无货代 RPA)。"""
|
|
task = SimpleNamespace(
|
|
customer_resolution_status='confirmed',
|
|
process_status='waiting_upload',
|
|
pending_human_reason=None,
|
|
match_status='matched',
|
|
review_status=None,
|
|
export_file_name='SN-001.xlsx',
|
|
)
|
|
nodes = project_task_progress_nodes(task)
|
|
assert [item['code'] for item in nodes] == [item['code'] for item in STP_PROGRESS_NODE_DEFS]
|
|
by_code = {item['code']: item['status'] for item in nodes}
|
|
# 关键断言:前序节点已成功,货代等待人工上传登记。
|
|
assert by_code['customer_confirm'] == 'succeeded'
|
|
assert by_code['task_create'] == 'succeeded'
|
|
assert by_code['inventory_prepare'] == 'succeeded'
|
|
assert by_code['inventory_match'] == 'succeeded'
|
|
assert by_code['freight_upload'] == 'manual_takeover'
|
|
assert by_code['freight_upload'] != 'running'
|
|
assert derive_overall_node_status(nodes) == 'manual_takeover'
|
|
|
|
|
|
def test_progress_nodes_mark_inventory_rpa_retrying():
|
|
"""库存 RPA 等待中投影为 retrying/running,匹配节点保持 pending。"""
|
|
task = SimpleNamespace(
|
|
customer_resolution_status='confirmed',
|
|
process_status='waiting_inventory',
|
|
pending_human_reason='rpa_pending',
|
|
match_status=None,
|
|
review_status=None,
|
|
export_file_name=None,
|
|
)
|
|
nodes = project_task_progress_nodes(task)
|
|
by_code = {item['code']: item['status'] for item in nodes}
|
|
assert by_code['inventory_rpa'] == 'retrying'
|
|
assert by_code['inventory_match'] == 'pending'
|
|
assert by_code['freight_upload'] == 'pending'
|
|
|
|
|
|
def test_progress_nodes_customer_pending_blocks_downstream():
|
|
"""客户未确认时下游库存节点保持 pending。"""
|
|
task = SimpleNamespace(
|
|
customer_resolution_status='pending',
|
|
process_status='created',
|
|
pending_human_reason=None,
|
|
match_status=None,
|
|
review_status=None,
|
|
export_file_name=None,
|
|
)
|
|
nodes = project_task_progress_nodes(task)
|
|
by_code = {item['code']: item['status'] for item in nodes}
|
|
assert by_code['customer_confirm'] == 'pending'
|
|
assert by_code['task_create'] == 'succeeded'
|
|
assert by_code['inventory_prepare'] == 'pending'
|