refactor(shipping-notice): 统一料号字段,移除过时的 SKU 相关字段,更新相关逻辑以支持新字段命名

This commit is contained in:
hugo committed 2026-07-16 20:02:33 +08:00
1 parent dde25344ca
commit 46eb63f5bb
111 files changed
+3116 -1250

No files matched your search

@@ -1,7 +1,7 @@
"""
tests/test_shipping_notice_openapi_contract.py
用途:锁定发货通知订单行路由线索与库存连接器 OpenAPI 命名契约。
用途:锁定发货通知 v2 订单行、单一路由线索与库存连接器 OpenAPI 命名契约。
依赖:Flask 测试 client、静态 Dify OpenAPI JSON。
逻辑:分别校验动态 builder 输出与脚本生成的静态快照,防止两者发生漂移。
"""
@@ -17,8 +17,8 @@ def _assert_connector_contract(spec: dict[str, Any]) -> None:
"""
校验订单行与库存连接器的字段边界。
核心逻辑:订单行保留可选 source_type 与独立 hub_code;任务状态说明使用
inventory_connector_type,并拒绝旧 inventory_source_type 命名。
核心逻辑:订单行只接受 part_number 与可选外部料号/inventory_source_hint;
任务状态说明使用 inventory_connector_type,并拒绝旧 inventory_source_type 命名。
Args:
spec: 动态接口或静态快照读取出的 OpenAPI 对象。
@@ -30,9 +30,23 @@ def _assert_connector_contract(spec: dict[str, Any]) -> None:
"application/json"
]["schema"]["properties"]["orders"]["items"]
line_properties = order_schema["properties"]["lines"]["items"]["properties"]
assert set(line_properties) == {"sku", "qty", "reservation_id", "source_type", "hub_code"}
assert "可选订单路由线索" in line_properties["source_type"]["description"]
assert "Hub" in line_properties["hub_code"]["description"] or "hub" in line_properties["hub_code"]["description"].lower()
assert order_schema["properties"]["lines"]["items"]["additionalProperties"] is False
assert set(line_properties) == {
"part_number",
"customer_part_number",
"aws_part_number",
"qty",
"reservation_id",
"inventory_source_hint",
}
assert "库存来源提示" in line_properties["inventory_source_hint"]["description"]
assert not {"sku", "vendor_part_number", "source_type", "hub_code"} & set(line_properties)
request_schema = spec["paths"]["/tools/submit_order_extraction"]["post"]["requestBody"]["content"][
"application/json"
]["schema"]
assert "schema_version" not in request_schema["properties"]
assert request_schema["required"] == ["agent_runtime_context", "input_snapshot_hash", "orders"]
status_description = spec["paths"]["/tools/get_task_status"]["post"]["description"]
assert "inventory_connector_type" in status_description