统一货代发货通知的业务阶段为四个标准阶段:接收解析、订单复核、发货准备、上传完成 设置 ui_state 为前端唯一状态数据源,不再依赖 process_status 驱动业务流程 删除 shipping_notices 表的废弃 process_status 列及对应复合索引,新增数据库迁移脚本 替换全栈代码中所有对 process_status 的引用为生命周期、上传状态等领域字段 更新相关文档、测试用例与前端展示逻辑适配新的状态管理规则
65 lines
2.6 KiB
Python
65 lines
2.6 KiB
Python
"""
|
||
backend/tests/test_shipping_projection_cross_surface.py
|
||
|
||
用途:跨面一致性契约——15 阶顺序、OT stage 同步与密度窗口共享同一投影真相。
|
||
依赖:progress_audit_contract、order_task_service、frontend progressWindow 对齐的 BE 语义。
|
||
逻辑:阶段码集合一致;sync_order_task_processing_state 写入的 stage 必须属于
|
||
SHIPPING_PROCESSING_STAGES;inventory_source_resolving 在 waiting_review 之前。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from app import db
|
||
from app.models import ShippingNotice, ShippingOrderTask
|
||
from app.services.shipping_notice.order_task_service import sync_order_task_processing_state
|
||
from app.services.shipping_notice.progress_audit_contract import (
|
||
EML_ONLY_PROCESSING_STAGES,
|
||
SHIPPING_PROCESSING_STAGES,
|
||
)
|
||
|
||
|
||
def test_fifteen_stages_inventory_source_before_review():
|
||
"""库存源解析必须排在人工复核与建单之前(跨面共用同一有序元组)。"""
|
||
stages = list(SHIPPING_PROCESSING_STAGES)
|
||
assert len(stages) == 15
|
||
assert stages.index('inventory_source_resolving') < stages.index('waiting_review')
|
||
assert stages.index('waiting_review') < stages.index('order_creating')
|
||
assert stages.index('inventory_matching') < stages.index('excel_generating')
|
||
assert 'email_parsing' in EML_ONLY_PROCESSING_STAGES
|
||
assert 'email_adjudicating' in EML_ONLY_PROCESSING_STAGES
|
||
|
||
|
||
def test_sync_order_task_stage_must_be_processing_stage(app):
|
||
"""任务工作台与对话投影均读 OT.stage;写入值必须是冻结的 15 阶之一。"""
|
||
with app.app_context():
|
||
notice = ShippingNotice(
|
||
task_no='SN-CROSS-SURFACE-001',
|
||
source_type='manual',
|
||
po_number='PO-CROSS-001',
|
||
order_lines_migration_status='pending',
|
||
)
|
||
db.session.add(notice)
|
||
db.session.flush()
|
||
order_task = ShippingOrderTask(
|
||
task_no='OT-CROSS-SURFACE-001',
|
||
user_id=1,
|
||
shipping_notice_id=int(notice.id),
|
||
stage='waiting_review',
|
||
status='waiting_review',
|
||
progress_version=1,
|
||
)
|
||
db.session.add(order_task)
|
||
db.session.flush()
|
||
|
||
sync_order_task_processing_state(
|
||
order_task,
|
||
stage='inventory_matching',
|
||
status='processing',
|
||
)
|
||
db.session.commit()
|
||
|
||
refreshed = db.session.get(ShippingOrderTask, order_task.id)
|
||
assert refreshed.stage == 'inventory_matching'
|
||
assert refreshed.stage in SHIPPING_PROCESSING_STAGES
|
||
assert int(refreshed.progress_version or 0) >= 2
|