You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.5 KiB
71 lines
1.5 KiB
|
2 months ago
|
"""
|
||
|
|
测试中心Schema
|
||
|
|
"""
|
||
|
|
from datetime import datetime
|
||
|
|
from typing import List, Optional, Dict, Any
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class TestCategory(BaseModel):
|
||
|
|
"""测试分类"""
|
||
|
|
key: str
|
||
|
|
name: str
|
||
|
|
|
||
|
|
|
||
|
|
class TestEndpoint(BaseModel):
|
||
|
|
"""测试端点"""
|
||
|
|
category: str
|
||
|
|
name: str
|
||
|
|
endpoint: str
|
||
|
|
method: str
|
||
|
|
params: Optional[Dict[str, Any]] = None
|
||
|
|
description: Optional[str] = None
|
||
|
|
|
||
|
|
|
||
|
|
class TestRequest(BaseModel):
|
||
|
|
"""测试请求"""
|
||
|
|
endpoint: str
|
||
|
|
method: str = "GET"
|
||
|
|
params: Optional[Dict[str, Any]] = None
|
||
|
|
|
||
|
|
|
||
|
|
class TestResponse(BaseModel):
|
||
|
|
"""测试响应"""
|
||
|
|
success: bool
|
||
|
|
endpoint: str
|
||
|
|
method: str
|
||
|
|
status_code: Optional[int] = None
|
||
|
|
execution_time_ms: Optional[int] = None
|
||
|
|
response_data: Optional[Any] = None
|
||
|
|
error_message: Optional[str] = None
|
||
|
|
|
||
|
|
|
||
|
|
class TestHistoryResponse(BaseModel):
|
||
|
|
"""测试历史响应"""
|
||
|
|
id: int
|
||
|
|
test_name: str
|
||
|
|
api_category: str
|
||
|
|
api_endpoint: str
|
||
|
|
request_method: str
|
||
|
|
status_code: Optional[int]
|
||
|
|
execution_time_ms: Optional[int]
|
||
|
|
is_success: bool
|
||
|
|
error_message: Optional[str]
|
||
|
|
created_at: datetime
|
||
|
|
|
||
|
|
class Config:
|
||
|
|
from_attributes = True
|
||
|
|
|
||
|
|
|
||
|
|
class RunAllTestsRequest(BaseModel):
|
||
|
|
"""运行全部测试请求"""
|
||
|
|
categories: List[str] = Field(default=["base_data", "stock", "future", "finance"])
|
||
|
|
|
||
|
|
|
||
|
|
class RunAllTestsResponse(BaseModel):
|
||
|
|
"""运行全部测试响应"""
|
||
|
|
total: int
|
||
|
|
passed: int
|
||
|
|
failed: int
|
||
|
|
results: List[TestResponse]
|