feat(shipping-notice): 完善发货通知自动推进与多库存源复核闭环

This commit is contained in:
hugo committed 2026-08-09 11:43:53 +08:00
1 parent cfa19a0b7b
commit 8e0bbf7a81
180 files changed
+31210 -1864

No files matched your search

@@ -15,6 +15,7 @@ from app.services.shipping_notice.task_retry_decision_service import (
ACTION_FETCH_INVENTORY,
ACTION_NOOP,
decide_retry_action_only,
_is_inventory_rpa_active,
)
@@ -73,3 +74,52 @@ def test_decide_rpa_pending_already_running():
decided = decide_retry_action_only(task, scope='task')
assert decided['action'] == ACTION_NOOP
assert decided['reason_code'] == 'already_running'
def test_structured_failed_attempt_overrides_stale_rpa_pending(monkeypatch):
"""逐源 Attempt 已失败时,旧 rpa_pending 摘要不得阻止用户手动重试。"""
task = _task(task_no='OT-FAILED', pending_human_reason='rpa_pending')
class _Query:
calls = 0
def filter(self, *_args):
return self
def order_by(self, *_args):
return self
def first(self):
self.calls += 1
if self.calls == 1:
return None
return SimpleNamespace(status='failed')
monkeypatch.setattr(
'app.models.ShippingTaskInventoryRpaAttempt.query',
_Query(),
raising=False,
)
assert _is_inventory_rpa_active(task) is False
def test_structured_running_attempt_blocks_duplicate_retry(monkeypatch):
"""逐源 Attempt 仍在运行时,必须拦截重复派发。"""
task = _task(task_no='OT-RUNNING', pending_human_reason=None)
class _Query:
def filter(self, *_args):
return self
def order_by(self, *_args):
return self
def first(self):
return SimpleNamespace(status='running')
monkeypatch.setattr(
'app.models.ShippingTaskInventoryRpaAttempt.query',
_Query(),
raising=False,
)
assert _is_inventory_rpa_active(task) is True