mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
fix: base model for TestSuite
This commit is contained in:
@@ -17,7 +17,7 @@ class JsonSchemaChecker(object):
|
||||
Api.parse_obj(content)
|
||||
except ValidationError as ex:
|
||||
logger.error(ex)
|
||||
raise exceptions.FileFormatError
|
||||
raise exceptions.FileFormatError(ex)
|
||||
|
||||
@staticmethod
|
||||
def validate_testcase_format(content):
|
||||
@@ -27,7 +27,7 @@ class JsonSchemaChecker(object):
|
||||
TestCase.parse_obj(content)
|
||||
except ValidationError as ex:
|
||||
logger.error(ex)
|
||||
raise exceptions.FileFormatError
|
||||
raise exceptions.FileFormatError(ex)
|
||||
|
||||
@staticmethod
|
||||
def validate_testsuite_format(content):
|
||||
@@ -37,7 +37,7 @@ class JsonSchemaChecker(object):
|
||||
TestSuite.parse_obj(content)
|
||||
except ValidationError as ex:
|
||||
logger.error(ex)
|
||||
raise exceptions.FileFormatError
|
||||
raise exceptions.FileFormatError(ex)
|
||||
|
||||
|
||||
def is_test_path(path):
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from .api import Api
|
||||
from .testcase import ProjectMeta, TestCase, TestCases
|
||||
from .testcase import ProjectMeta, TestCase
|
||||
from .testsuite import TestSuite
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from typing import Dict, Text
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from httprunner.schema import common
|
||||
@@ -10,5 +12,5 @@ class Api(BaseModel):
|
||||
base_url: common.BaseUrl = ""
|
||||
setup_hooks: common.Hook = []
|
||||
teardown_hooks: common.Hook = []
|
||||
extract: common.Extract = {}
|
||||
extract: Dict[Text, Text] = {}
|
||||
validation: common.Validate = Field([], alias="validate")
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
from enum import Enum
|
||||
from typing import Dict, List, Any
|
||||
from typing import Dict, List, Any, Text
|
||||
|
||||
from pydantic import BaseModel, HttpUrl, Field
|
||||
|
||||
Name = str
|
||||
Url = str
|
||||
Name = Text
|
||||
Url = Text
|
||||
BaseUrl = HttpUrl
|
||||
Variables = Dict[str, Any]
|
||||
Headers = Dict[str, str]
|
||||
Variables = Dict[Text, Any]
|
||||
Headers = Dict[Text, Text]
|
||||
Verify = bool
|
||||
Hook = List[str]
|
||||
Export = List[str]
|
||||
Extract = Dict[str, str]
|
||||
Hook = List[Text]
|
||||
Export = List[Text]
|
||||
Validate = List[Dict]
|
||||
Env = Dict[str, Any]
|
||||
Env = Dict[Text, Any]
|
||||
|
||||
|
||||
class MethodEnum(str, Enum):
|
||||
class MethodEnum(Text, Enum):
|
||||
GET = 'GET'
|
||||
POST = 'POST'
|
||||
PUT = "PUT"
|
||||
@@ -52,10 +51,10 @@ class TestsConfig(BaseModel):
|
||||
class Request(BaseModel):
|
||||
method: MethodEnum = MethodEnum.GET
|
||||
url: Url
|
||||
params: Dict[str, str] = {}
|
||||
params: Dict[Text, Text] = {}
|
||||
headers: Headers = {}
|
||||
req_json: Dict = Field({}, alias="json")
|
||||
cookies: Dict[str, str] = {}
|
||||
cookies: Dict[Text, Text] = {}
|
||||
timeout: int = 120
|
||||
allow_redirects: bool = True
|
||||
verify: Verify = False
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Dict, List, Text
|
||||
from typing import Dict, List, Text, Union
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
@@ -13,9 +13,10 @@ class ProjectMeta(BaseModel):
|
||||
|
||||
class TestStep(BaseModel):
|
||||
name: common.Name
|
||||
api: str = None # TODO: replace with FilePath
|
||||
api: Text = None # TODO: replace with FilePath
|
||||
testcase: Text = None
|
||||
request: common.Request = None
|
||||
extract: Dict[str, str] = {}
|
||||
extract: Union[Dict[Text, Text], List[Text]] = {}
|
||||
validation: common.Validate = Field([], alias="validate")
|
||||
|
||||
|
||||
@@ -81,6 +82,3 @@ class TestCase(BaseModel):
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
TestCases = List[TestCase]
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
from typing import List
|
||||
from typing import List, Text
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from httprunner.schema import common, TestCase
|
||||
from httprunner.schema import common
|
||||
|
||||
|
||||
class TestCase(BaseModel):
|
||||
name: common.Name
|
||||
testcase: Text
|
||||
weight: int = 1
|
||||
variables: common.Variables = {}
|
||||
|
||||
|
||||
class TestSuite(BaseModel):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
config:
|
||||
name: create users with uid
|
||||
variables:
|
||||
- device_sn: ${gen_random_string(15)}
|
||||
device_sn: ${gen_random_string(15)}
|
||||
base_url: "http://127.0.0.1:5000"
|
||||
|
||||
testcases:
|
||||
|
||||
Reference in New Issue
Block a user