fix(exchange,case_validator),refactor(),feat(model): 解决 Pydantic 模型初始化与变量占位符的类型冲突,优化变量替换逻辑,重构 CaseInfo 模型并引入延迟校验机制

- 引入 SmartInt 和 SmartDict 类型,支持 YAML 占位符与业务类型的自动转换。
- 优化 CaseInfo 互斥校验逻辑,确保 request 与 api_action 二选一。
- 统一使用 Pydantic V2 的 model_config 规范。
- 将变量替换时机提前至模型实例化之前,支持占位符在校验前完成真实值注入,
保证了 int/bool 等字段的类型转换正确性。
- 优化断言渲染时机,支持响应提取值关联。
This commit is contained in:
2026-03-11 10:29:16 +08:00
parent 69a96a0060
commit 293b5160fe
39 changed files with 1359 additions and 1031 deletions

11
api/__init__.py Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env python
# coding=utf-8
"""
@author: chen wei
@Software: PyCharm
@contact: t6i888@163.com
@file: __init__.py
@date: 2024 2024/9/15 21:13
@desc:
"""

32
api/user_api.py Normal file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env python
# coding=utf-8
from core.base_api import BaseApi
class UserApi(BaseApi):
"""用户中心业务接口"""
def login(self, username, password):
"""登录接口示例"""
self._log_action("login", user=username)
payload = {
"username": username,
"password": password
}
# 直接调用继承自 session 的请求方法
return self.session.request(
method="POST",
url="/api/v1/login",
json=payload
)
def get_info(self, user_id: int):
"""获取用户信息示例"""
self._log_action("get_info", uid=user_id)
return self.session.request(
method="GET",
url=f"/api/v1/user/{user_id}"
)