mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 19:39:44 +08:00
change: remove compatibility with testsuite format v1
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
**Changed**
|
||||
|
||||
- remove compatibility with testcase format v1
|
||||
- remove compatibility with testcase/testsuite format v1
|
||||
|
||||
## 3.0.1 (2020-03-24)
|
||||
|
||||
|
||||
@@ -189,23 +189,6 @@ def load_testsuite(raw_testsuite):
|
||||
|
||||
Args:
|
||||
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": {
|
||||
"name": "xxx",
|
||||
@@ -232,28 +215,18 @@ def load_testsuite(raw_testsuite):
|
||||
"""
|
||||
raw_testcases = raw_testsuite["testcases"]
|
||||
|
||||
if isinstance(raw_testcases, dict):
|
||||
# format version 1, make compatible with version < 2.2.0
|
||||
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:
|
||||
# TODO: validate with pydantic
|
||||
if not isinstance(raw_testcases, list):
|
||||
# invalid 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
|
||||
|
||||
|
||||
|
||||
@@ -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")
|
||||
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")
|
||||
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")
|
||||
|
||||
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:
|
||||
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:
|
||||
testsuite_schema_v2 = json.load(f)
|
||||
|
||||
@@ -64,12 +60,6 @@ class JsonSchemaChecker(object):
|
||||
"""
|
||||
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
|
||||
def validate_testsuite_v2_format(content):
|
||||
""" check testsuite format v2 if valid
|
||||
@@ -178,12 +168,6 @@ def is_test_content(data_structure):
|
||||
|
||||
for item in testsuites:
|
||||
is_testcase = False
|
||||
try:
|
||||
JsonSchemaChecker.validate_testsuite_v1_format(item)
|
||||
is_testcase = True
|
||||
except exceptions.FileFormatError:
|
||||
pass
|
||||
|
||||
try:
|
||||
JsonSchemaChecker.validate_testsuite_v2_format(item)
|
||||
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