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