fix 真实well数据覆盖

This commit is contained in:
gongwenxin
2025-08-19 18:19:23 +08:00
parent 7be36f694e
commit 2d5718a72f
2 changed files with 273 additions and 10 deletions
+29 -10
View File
@@ -376,6 +376,14 @@ class DmsCrudScenarioStage(BaseAPIStage):
self.logger.info(f"LLM生成数据已通过井数据管理器增强")
self.logger.info(f"LLM成功生成智能测试数据: {create_payload}")
# 🔑 关键修复:预构建请求体,避免测试编排器重新生成数据
stage_context["create_request_body"] = {
"version": "1.0.0",
"act": -1,
"data": [create_payload]
}
self.logger.info(f"预构建创建请求体完成")
else:
self.logger.warning("LLM生成的数据格式不符合预期,回退到传统数据生成")
raise ValueError("LLM数据格式无效")
@@ -419,11 +427,28 @@ class DmsCrudScenarioStage(BaseAPIStage):
update_payload = copy.deepcopy(create_payload)
update_payload["description"] = "updated-test-entry-from-scenario"
# 🔑 关键修复:预构建请求体,避免测试编排器重新生成数据
create_request_body = {
"version": "1.0.0",
"act": -1,
"data": [create_payload]
}
update_request_body = {
"version": "1.0.0",
"act": -1,
"data": [update_payload]
}
self.logger.info(f"预构建创建和更新请求体完成")
# Populate stage context
stage_context["pk_name"] = pk_name
stage_context["pk_value"] = pk_value
stage_context["current_payload"] = create_payload
stage_context["update_payload"] = update_payload
stage_context["create_request_body"] = create_request_body
stage_context["update_request_body"] = update_request_body
stage_context["scenario_endpoints"] = current_scenario
# Pre-build the delete body to avoid key-templating issues later
@@ -481,11 +506,8 @@ class DmsCrudScenarioStage(BaseAPIStage):
endpoint_spec_lookup_key="CREATE",
request_overrides={
# DMS标准格式:包含version、act和data字段
"body": {
"version": "1.0.0",
"act": -1,
"data": ["{{stage_context.current_payload}}"]
}
# 使用预生成的数据,避免测试编排器重新生成
"body": "{{stage_context.create_request_body}}"
},
response_assertions=[validate_response_is_true],
outputs_to_context={}
@@ -504,11 +526,8 @@ class DmsCrudScenarioStage(BaseAPIStage):
endpoint_spec_lookup_key="UPDATE",
request_overrides={
# DMS标准格式:包含version、act和data字段
"body": {
"version": "1.0.0",
"act": -1,
"data": ["{{stage_context.update_payload}}"]
}
# 使用预生成的数据,避免测试编排器重新生成
"body": "{{stage_context.update_request_body}}"
},
response_assertions=[validate_response_is_true]
),