mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-01 13:59:37 +08:00
change: remove compatibility with testsuite format v1
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
**Changed**
|
**Changed**
|
||||||
|
|
||||||
- remove compatibility with testcase format v1
|
- remove compatibility with testcase/testsuite format v1
|
||||||
|
|
||||||
## 3.0.1 (2020-03-24)
|
## 3.0.1 (2020-03-24)
|
||||||
|
|
||||||
|
|||||||
@@ -189,23 +189,6 @@ def load_testsuite(raw_testsuite):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
raw_testsuite (dict): raw testsuite content loaded from JSON/YAML file:
|
raw_testsuite (dict): raw testsuite content loaded from JSON/YAML file:
|
||||||
# version 1, compatible with version < 2.2.0
|
|
||||||
{
|
|
||||||
"config": {
|
|
||||||
"name": "xxx",
|
|
||||||
"variables": {}
|
|
||||||
}
|
|
||||||
"testcases": {
|
|
||||||
"testcase1": {
|
|
||||||
"testcase": "/path/to/testcase",
|
|
||||||
"variables": {...},
|
|
||||||
"parameters": {...}
|
|
||||||
},
|
|
||||||
"testcase2": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# version 2, implemented in 2.2.0
|
|
||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"name": "xxx",
|
"name": "xxx",
|
||||||
@@ -232,28 +215,18 @@ def load_testsuite(raw_testsuite):
|
|||||||
"""
|
"""
|
||||||
raw_testcases = raw_testsuite["testcases"]
|
raw_testcases = raw_testsuite["testcases"]
|
||||||
|
|
||||||
if isinstance(raw_testcases, dict):
|
# TODO: validate with pydantic
|
||||||
# format version 1, make compatible with version < 2.2.0
|
if not isinstance(raw_testcases, list):
|
||||||
JsonSchemaChecker.validate_testsuite_v1_format(raw_testsuite)
|
|
||||||
raw_testsuite["testcases"] = {}
|
|
||||||
for name, raw_testcase in raw_testcases.items():
|
|
||||||
__extend_with_testcase_ref(raw_testcase)
|
|
||||||
raw_testcase.setdefault("name", name)
|
|
||||||
raw_testsuite["testcases"][name] = raw_testcase
|
|
||||||
|
|
||||||
elif isinstance(raw_testcases, list):
|
|
||||||
# format version 2, implemented in 2.2.0
|
|
||||||
JsonSchemaChecker.validate_testsuite_v2_format(raw_testsuite)
|
|
||||||
raw_testsuite["testcases"] = {}
|
|
||||||
for raw_testcase in raw_testcases:
|
|
||||||
__extend_with_testcase_ref(raw_testcase)
|
|
||||||
testcase_name = raw_testcase["name"]
|
|
||||||
raw_testsuite["testcases"][testcase_name] = raw_testcase
|
|
||||||
|
|
||||||
else:
|
|
||||||
# invalid format
|
# invalid format
|
||||||
raise exceptions.FileFormatError("Invalid testsuite format!")
|
raise exceptions.FileFormatError("Invalid testsuite format!")
|
||||||
|
|
||||||
|
JsonSchemaChecker.validate_testsuite_v2_format(raw_testsuite)
|
||||||
|
raw_testsuite["testcases"] = {}
|
||||||
|
for raw_testcase in raw_testcases:
|
||||||
|
__extend_with_testcase_ref(raw_testcase)
|
||||||
|
testcase_name = raw_testcase["name"]
|
||||||
|
raw_testsuite["testcases"][testcase_name] = raw_testcase
|
||||||
|
|
||||||
return raw_testsuite
|
return raw_testsuite
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ schemas_root_dir = os.path.join(os.path.dirname(__file__), "schemas")
|
|||||||
common_schema_path = os.path.join(schemas_root_dir, "common.schema.json")
|
common_schema_path = os.path.join(schemas_root_dir, "common.schema.json")
|
||||||
api_schema_path = os.path.join(schemas_root_dir, "api.schema.json")
|
api_schema_path = os.path.join(schemas_root_dir, "api.schema.json")
|
||||||
testcase_schema_v2_path = os.path.join(schemas_root_dir, "testcase.schema.v2.json")
|
testcase_schema_v2_path = os.path.join(schemas_root_dir, "testcase.schema.v2.json")
|
||||||
testsuite_schema_v1_path = os.path.join(schemas_root_dir, "testsuite.schema.v1.json")
|
|
||||||
testsuite_schema_v2_path = os.path.join(schemas_root_dir, "testsuite.schema.v2.json")
|
testsuite_schema_v2_path = os.path.join(schemas_root_dir, "testsuite.schema.v2.json")
|
||||||
|
|
||||||
with io.open(api_schema_path, encoding='utf-8') as f:
|
with io.open(api_schema_path, encoding='utf-8') as f:
|
||||||
@@ -31,9 +30,6 @@ with io.open(common_schema_path, encoding='utf-8') as f:
|
|||||||
with io.open(testcase_schema_v2_path, encoding='utf-8') as f:
|
with io.open(testcase_schema_v2_path, encoding='utf-8') as f:
|
||||||
testcase_schema_v2 = json.load(f)
|
testcase_schema_v2 = json.load(f)
|
||||||
|
|
||||||
with io.open(testsuite_schema_v1_path, encoding='utf-8') as f:
|
|
||||||
testsuite_schema_v1 = json.load(f)
|
|
||||||
|
|
||||||
with io.open(testsuite_schema_v2_path, encoding='utf-8') as f:
|
with io.open(testsuite_schema_v2_path, encoding='utf-8') as f:
|
||||||
testsuite_schema_v2 = json.load(f)
|
testsuite_schema_v2 = json.load(f)
|
||||||
|
|
||||||
@@ -64,12 +60,6 @@ class JsonSchemaChecker(object):
|
|||||||
"""
|
"""
|
||||||
return JsonSchemaChecker.validate_format(content, testcase_schema_v2)
|
return JsonSchemaChecker.validate_format(content, testcase_schema_v2)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def validate_testsuite_v1_format(content):
|
|
||||||
""" check testsuite format v1 if valid
|
|
||||||
"""
|
|
||||||
return JsonSchemaChecker.validate_format(content, testsuite_schema_v1)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def validate_testsuite_v2_format(content):
|
def validate_testsuite_v2_format(content):
|
||||||
""" check testsuite format v2 if valid
|
""" check testsuite format v2 if valid
|
||||||
@@ -178,12 +168,6 @@ def is_test_content(data_structure):
|
|||||||
|
|
||||||
for item in testsuites:
|
for item in testsuites:
|
||||||
is_testcase = False
|
is_testcase = False
|
||||||
try:
|
|
||||||
JsonSchemaChecker.validate_testsuite_v1_format(item)
|
|
||||||
is_testcase = True
|
|
||||||
except exceptions.FileFormatError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
JsonSchemaChecker.validate_testsuite_v2_format(item)
|
JsonSchemaChecker.validate_testsuite_v2_format(item)
|
||||||
is_testcase = True
|
is_testcase = True
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "http://json-schema.org/draft-07/schema",
|
|
||||||
"description": "httprunner testsuite schema v1 definition",
|
|
||||||
"type": "object",
|
|
||||||
"definitions": {
|
|
||||||
"testcase": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"name": {
|
|
||||||
"$ref": "common.schema.json#/definitions/name"
|
|
||||||
},
|
|
||||||
"variables": {
|
|
||||||
"$ref": "common.schema.json#/definitions/variables"
|
|
||||||
},
|
|
||||||
"parameters": {
|
|
||||||
"description": "generate cartesian product variables with parameters, each group of variables will be run once",
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"testcase": {
|
|
||||||
"description": "testcase reference, value is testcase file relative path",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"testcase"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": {
|
|
||||||
"config": {
|
|
||||||
"$ref": "common.schema.json#/definitions/config"
|
|
||||||
},
|
|
||||||
"testcases": {
|
|
||||||
"description": "testcase of a testsuite",
|
|
||||||
"type": "object",
|
|
||||||
"minProperties": 1,
|
|
||||||
"patternProperties": {
|
|
||||||
".*": {
|
|
||||||
"description": "testcase definition",
|
|
||||||
"$ref": "testsuite.schema.v1.json#/definitions/testcase"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"config",
|
|
||||||
"testcases"
|
|
||||||
],
|
|
||||||
"examples": [
|
|
||||||
{
|
|
||||||
"config": {
|
|
||||||
"name": "testsuite name"
|
|
||||||
},
|
|
||||||
"testcases": {
|
|
||||||
"testcase 1": {
|
|
||||||
"name": "testcase 1",
|
|
||||||
"testcase": "/path/to/testcase1"
|
|
||||||
},
|
|
||||||
"testcase 2": {
|
|
||||||
"name": "testcase 2",
|
|
||||||
"testcase": "/path/to/testcase2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user