add 真实well数据覆盖

This commit is contained in:
gongwenxin 2025-08-19 17:09:11 +08:00
parent 4875a68f1c
commit 75d42b7aab
3 changed files with 105 additions and 35 deletions

View File

@ -534,29 +534,7 @@ class APITestOrchestrator:
else: else:
self.logger.info("No stages_dir provided, stage testing will be skipped.") self.logger.info("No stages_dir provided, stage testing will be skipped.")
def initialize_well_data(self) -> bool: # 完成其他初始化
"""
初始化井数据在测试开始前获取真实的井和井筒数据
Returns:
bool: 是否成功初始化井数据
"""
if not self.well_data_manager:
self.logger.info("井数据管理器未启用,跳过井数据初始化")
return False
try:
success = self.well_data_manager.initialize_well_data()
if success:
summary = self.well_data_manager.get_well_data_summary()
self.logger.info(f"井数据初始化成功: {summary}")
return success
except Exception as e:
self.logger.error(f"井数据初始化失败: {e}")
return False
def _complete_initialization(self, output_dir: Optional[str], strictness_level: Optional[str]):
"""完成初始化过程"""
self.output_dir_path = Path(output_dir) if output_dir else Path("./test_reports_orchestrator") self.output_dir_path = Path(output_dir) if output_dir else Path("./test_reports_orchestrator")
try: try:
self.output_dir_path.mkdir(parents=True, exist_ok=True) self.output_dir_path.mkdir(parents=True, exist_ok=True)
@ -583,8 +561,26 @@ class APITestOrchestrator:
self.json_schema_validator: Optional[JSONSchemaValidator] = None self.json_schema_validator: Optional[JSONSchemaValidator] = None
self.schema_provider: Optional[SchemaProvider] = None self.schema_provider: Optional[SchemaProvider] = None
# 完成初始化 def initialize_well_data(self) -> bool:
self._complete_initialization(output_dir, strictness_level) """
初始化井数据在测试开始前获取真实的井和井筒数据
Returns:
bool: 是否成功初始化井数据
"""
if not self.well_data_manager:
self.logger.info("井数据管理器未启用,跳过井数据初始化")
return False
try:
success = self.well_data_manager.initialize_well_data()
if success:
summary = self.well_data_manager.get_well_data_summary()
self.logger.info(f"井数据初始化成功: {summary}")
return success
except Exception as e:
self.logger.error(f"井数据初始化失败: {e}")
return False
def get_api_call_details(self) -> List[APICallDetail]: def get_api_call_details(self) -> List[APICallDetail]:
"""Returns the collected list of API call details.""" """Returns the collected list of API call details."""

View File

@ -14,10 +14,11 @@
- **错误处理**: 当井数据获取失败时,自动回退到模拟数据 - **错误处理**: 当井数据获取失败时,自动回退到模拟数据
### 支持的字段 ### 支持的字段
- `wellId` / `well_id` - 井ID - `wellId` - 井ID严格匹配字段名
- `wellboreId` / `wellbore_id` - 井筒ID - `wellboreId` - 井筒ID严格匹配字段名
- `wellCommonName` / `well_common_name` - 井通用名称 - `wellCommonName` - 井通用名称(严格匹配字段名)
- `wellboreCommonName` / `wellbore_common_name` - 井筒通用名称
> **注意**: 字段名称严格按照DMS接口规范不支持变体命名如well_id、WELL_ID等
## 🏗️ 架构设计 ## 🏗️ 架构设计

73
test_orchestrator_init.py Normal file
View File

@ -0,0 +1,73 @@
#!/usr/bin/env python3
"""
测试APITestOrchestrator初始化的脚本
"""
import sys
import logging
from ddms_compliance_suite.test_orchestrator import APITestOrchestrator
def test_orchestrator_initialization():
"""测试APITestOrchestrator的初始化"""
# 设置日志
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
logger.info("开始测试APITestOrchestrator初始化...")
try:
# 初始化编排器
orchestrator = APITestOrchestrator(
base_url="https://www.dev.ideas.cnpc",
strictness_level="CRITICAL",
ignore_ssl=True,
enable_well_data=True
)
# 检查关键属性是否正确初始化
logger.info("✅ APITestOrchestrator初始化成功")
# 检查strictness_level属性
if hasattr(orchestrator, 'strictness_level'):
logger.info(f"✅ strictness_level属性存在: {orchestrator.strictness_level}")
else:
logger.error("❌ strictness_level属性不存在")
return False
# 检查井数据管理器
if hasattr(orchestrator, 'well_data_manager'):
if orchestrator.well_data_manager:
logger.info("✅ 井数据管理器已初始化")
else:
logger.info(" 井数据管理器未启用")
else:
logger.error("❌ well_data_manager属性不存在")
return False
# 检查其他关键属性
required_attrs = [
'base_url', 'api_caller', 'test_case_registry',
'global_api_call_details', 'ignore_ssl', 'llm_config',
'output_dir_path', 'schema_cache', 'parser'
]
for attr in required_attrs:
if hasattr(orchestrator, attr):
logger.info(f"{attr}属性存在")
else:
logger.error(f"{attr}属性不存在")
return False
logger.info("🎉 所有属性检查通过")
return True
except Exception as e:
logger.error(f"❌ APITestOrchestrator初始化失败: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == "__main__":
success = test_orchestrator_initialization()
sys.exit(0 if success else 1)