- 退役 erp_adapter/gateway_adapter:外部查询/写经 capability_client 走集成连接器,端点凭据与并发超时由客户端实例管理 - 域能力代码注册 capabilities:入参出参 Schema、幂等语义与读写标志随域代码版本化,组合根 create_app 幂等注册 - 新增调拨业务类型 transfer_type(在途仓至HUB/HUB维修出/HUB间)冻结枚举,迁移落 CheckConstraint 数据库兜底 - 外部仓库映射新增 in_transit_warehouse_code 拨出库位来源,管理端库存映射页同步维护 - 单据命名外部化:erp_* 字段与索引改称 external_*,单据号格式交由连接器映射,测试数据同步换牌 - 收料归档文件可用性判定收敛 receipt_file_gate 单一事实来源(当天抓取/保留期/清理态) - 同步 chat 调拨卡片、useChatTransfer、e2e、全套服务/API/Job 测试与域文档
45 lines
1.8 KiB
Python
45 lines
1.8 KiB
Python
"""在途调拨测试断言辅助。
|
|
|
|
用途:统一断言外部调用次数、审计字段完整率与 Hash 可复算。
|
|
依赖:fakes.ExternalCallRecord。
|
|
逻辑:所有副作用断言优先读 Fake 的 call log,不猜测实现内部状态。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from decimal import Decimal
|
|
from typing import Any
|
|
|
|
from tests.services.in_transit_transfer.fakes import ExternalCallRecord, FakeCapabilityClient
|
|
|
|
|
|
def assert_erp_calls(erp: FakeCapabilityClient, expected: int, *, invoice_no: str | None = None) -> None:
|
|
"""断言 外部系统 调用次数(可按 Invoice 过滤)。"""
|
|
calls = erp.calls(invoice_no=invoice_no)
|
|
assert len(calls) == expected, f"expected {expected} 外部系统 calls, got {len(calls)}: {calls}"
|
|
|
|
|
|
def assert_external_write_zero(erp: FakeCapabilityClient) -> None:
|
|
"""断言没有任何 外部系统 写调用(fail-closed 场景通用断言)。"""
|
|
writes = erp.write_calls()
|
|
assert not writes, f"unexpected 外部系统 write calls: {writes}"
|
|
|
|
|
|
def assert_call_fields(record: ExternalCallRecord) -> None:
|
|
"""断言单次 外部系统 调用携带全部必需追踪字段。"""
|
|
assert record.operation_id
|
|
assert record.invoice_no
|
|
assert record.external_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}"
|