first commit

This commit is contained in:
strepsiades
2026-03-09 16:31:42 +08:00
commit 4a9c444b10
486 changed files with 52479 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
from __future__ import annotations
from typing import Any
from auto_test_domains.base import build_domain_report, make_local_data_id, run_pipeline_round
REMOTE_PROJECT_ID = "f3e02e84-e81c-4aa6-88d4-f5aa108c8227"
LOCAL_PROJECT_ID = make_local_data_id("project", REMOTE_PROJECT_ID)
def run_case(config: dict[str, Any], report_root) -> dict[str, Any]:
"""
contract domain 的批量回归脚本。
这里故意不用 yaml 驱动每一轮,而是直接用 Python 写出来,
这样每个用例在代码里都能看清楚“为什么要跑”和“跑完看什么”。
以 filtered_datasource 中的批量合同数据作为基础数据集,
再用两轮 overlay 聚焦验证一条目标合同的 create / update 行为。
当前保留两个核心用例:
1. round_1_create
- 目的:确认一条合同可以正常创建到远端。
- 判断方式:
- pipeline 返回码必须是 0
- 合同必须建立绑定;
2. round_2_update
- 目的:确认对同一条合同修改几个典型字段后,系统还能继续识别并推送 update。
- 本轮修改字段:
- total_price
- manager_name
- manager_phone
- sign_date
- 判断方式:
- pipeline 返回码必须是 0
- 绑定仍然存在;
- 数据集中的预期变更字段必须真的发生了变化。
"""
dataset_root = f"{config['project_root']}/tests/fixtures/auto_sync/datasource/contract"
filtered_root = f"{config['project_root']}/filtered_datasource/datasource/filtered"
base_dataset_files = [
"company_1.jsonl",
"project_1.jsonl",
"supplier_1.jsonl",
"contract_1.jsonl",
]
local_contract_id = "92e3de18-354c-4acf-9cb5-58ee55708fbd"
project_id_remap = {
"remote_project_id": REMOTE_PROJECT_ID,
"local_project_id": LOCAL_PROJECT_ID,
"remap_node_types": {"project"},
}
rounds: list[dict[str, Any]] = []
# 用例 1:创建合同
round_1 = run_pipeline_round(
config=config,
dataset_dir=f"{dataset_root}/round_1_create",
previous_dataset_dir=None,
base_dataset_dir=filtered_root,
base_dataset_files=base_dataset_files,
domain_name="contract",
round_name="round_1_create",
purpose="首轮创建合同",
required_bindings={"contract": [local_contract_id]},
project_id_remap=project_id_remap,
report_root=report_root,
)
rounds.append(round_1)
# 用例 2:更新合同几个基础字段
round_2 = run_pipeline_round(
config=config,
dataset_dir=f"{dataset_root}/round_2_update",
previous_dataset_dir=f"{dataset_root}/round_1_create",
base_dataset_dir=filtered_root,
base_dataset_files=base_dataset_files,
domain_name="contract",
round_name="round_2_update",
purpose="第二轮修改合同金额、负责人和签约日期,验证 update",
expected_changes={
"contract": {
local_contract_id: [
"total_price",
"manager_name",
"manager_phone",
"sign_date",
]
}
},
required_bindings={"contract": [local_contract_id]},
project_id_remap=project_id_remap,
report_root=report_root,
)
rounds.append(round_2)
return build_domain_report(
domain="contract",
description="合同 domain 的批量闭环测试。基于 filtered_datasource 中的批量 company/project/supplier/contract 数据,先建立合同绑定,再修改其中 1 条合同,检查批量场景下的绑定、状态库和 update 行为。",
rounds=rounds,
)