chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑

This commit is contained in:
hugo committed 2026-08-17 19:56:51 +08:00
1 parent 5ef8329bd8
commit 4ec4e57005
183 files changed
+14653 -3936

No files matched your search

@@ -14,7 +14,10 @@ from unittest.mock import MagicMock, patch
import pytest
from app.core.errors import ConflictError
from app.services.shipping_notice.processing_ownership import assert_notice_task_ownership
from app.services.shipping_notice.processing_ownership import (
assert_notice_task_ownership,
record_projection_inconsistency_audit,
)
from app.services.shipping_notice.processing_projection_invariants import (
PROJECTION_INCONSISTENT_ERROR_CODE,
TASK_OWNERSHIP_MISMATCH_ERROR_CODE,
@@ -65,6 +68,24 @@ def test_reconcile_marks_inconsistency_and_strips_fulfillment():
assert len(payload['stage_nodes']) == 15
def test_projection_inconsistency_audit_uses_allowed_failure_result(app):
"""不一致审计必须以 audit_service 接受的 failure 落库,不能在 GET 路径反复报参数非法。"""
with app.app_context():
with patch(
'app.services.shipping_notice.processing_ownership.append_shipping_audit_event',
) as append_mock, patch(
'app.services.shipping_notice.processing_ownership.db.session.flush',
):
record_projection_inconsistency_audit({
'projection_inconsistency_code': PROJECTION_INCONSISTENT_ERROR_CODE,
'work_item_no': 'OT-9',
'shipping_notice_no': 'SN-9',
'stage': 'waiting_review',
})
assert append_mock.call_args.kwargs['result'] == 'failure'
def test_assert_ownership_noop_without_expected_context():
"""未传期望 OT/Case/Run 时不拦截(兼容旧客户端)。"""
task = SimpleNamespace(id=1, task_no='SN-1', order_task_id=None)