Merge branch 'dev' into runny827
feat(training): 新增精益培训视频与周任务管理 # Conflicts: # backend/app/models/__init__.py
This commit is contained in:
1 parent
85d27e9ffa
commit
91b7233872
812 files changed
+73763
-18908
No files matched your search
@@ -0,0 +1,44 @@
|
||||
"""在途调拨测试断言辅助。
|
||||
|
||||
用途:统一断言外部调用次数、审计字段完整率与 Hash 可复算。
|
||||
依赖:fakes.ErpCallRecord。
|
||||
逻辑:所有副作用断言优先读 Fake 的 call log,不猜测实现内部状态。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from decimal import Decimal
|
||||
from typing import Any
|
||||
|
||||
from tests.services.in_transit_transfer.fakes import ErpCallRecord, FakeERP
|
||||
|
||||
|
||||
def assert_erp_calls(erp: FakeERP, expected: int, *, invoice_no: str | None = None) -> None:
|
||||
"""断言 ERP 调用次数(可按 Invoice 过滤)。"""
|
||||
calls = erp.calls(invoice_no=invoice_no)
|
||||
assert len(calls) == expected, f"expected {expected} ERP calls, got {len(calls)}: {calls}"
|
||||
|
||||
|
||||
def assert_erp_write_zero(erp: FakeERP) -> None:
|
||||
"""断言没有任何 ERP 写调用(fail-closed 场景通用断言)。"""
|
||||
writes = erp.write_calls()
|
||||
assert not writes, f"unexpected ERP write calls: {writes}"
|
||||
|
||||
|
||||
def assert_call_fields(record: ErpCallRecord) -> None:
|
||||
"""断言单次 ERP 调用携带全部必需追踪字段。"""
|
||||
assert record.operation_id
|
||||
assert record.invoice_no
|
||||
assert record.erp_org
|
||||
assert record.from_warehouse
|
||||
assert record.to_warehouse
|
||||
assert isinstance(record.quantity, Decimal)
|
||||
assert record.call_seq > 0
|
||||
assert record.returned_status
|
||||
|
||||
|
||||
def assert_audit_complete(event: dict[str, Any]) -> None:
|
||||
"""断言一条审计事件字段完整(操作者、关联、前后快照、Hash)。"""
|
||||
for key in ("event_type", "aggregate_type", "aggregate_id", "actor_type", "operation_id",
|
||||
"request_id", "before_hash", "after_hash", "event_hash"):
|
||||
assert event.get(key), f"audit event missing {key}: {event}"
|
||||
Reference in new issue
Block a user