mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
fix: json schema validation for testcase v2
This commit is contained in:
@@ -281,7 +281,6 @@ def load_testsuite(raw_testsuite):
|
|||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
JsonSchemaChecker.validate_testsuite_format(raw_testsuite)
|
|
||||||
raw_testcases = raw_testsuite.pop("testcases")
|
raw_testcases = raw_testsuite.pop("testcases")
|
||||||
raw_testsuite["testcases"] = {}
|
raw_testsuite["testcases"] = {}
|
||||||
|
|
||||||
@@ -293,6 +292,7 @@ def load_testsuite(raw_testsuite):
|
|||||||
raw_testsuite["testcases"][name] = raw_testcase
|
raw_testsuite["testcases"][name] = raw_testcase
|
||||||
|
|
||||||
elif isinstance(raw_testcases, list):
|
elif isinstance(raw_testcases, list):
|
||||||
|
JsonSchemaChecker.validate_testsuite_v2_format(raw_testsuite)
|
||||||
# format version 2, implemented in 2.2.0
|
# format version 2, implemented in 2.2.0
|
||||||
for raw_testcase in raw_testcases:
|
for raw_testcase in raw_testcases:
|
||||||
__extend_with_testcase_ref(raw_testcase)
|
__extend_with_testcase_ref(raw_testcase)
|
||||||
|
|||||||
@@ -39,16 +39,6 @@ class JsonSchemaChecker(object):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def validate_testsuite_format(content):
|
|
||||||
try:
|
|
||||||
jsonschema.validate(content, testsuite_schema_v2, resolver=resolver)
|
|
||||||
except jsonschema.exceptions.ValidationError as ex:
|
|
||||||
logger.log_error(str(ex))
|
|
||||||
raise exceptions.FileFormatError
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def validate_testcase_v1_format(content):
|
def validate_testcase_v1_format(content):
|
||||||
""" check testcase format v1 if valid
|
""" check testcase format v1 if valid
|
||||||
@@ -67,6 +57,18 @@ class JsonSchemaChecker(object):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def validate_testsuite_v2_format(content):
|
||||||
|
""" check testsuite format v2 if valid
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
jsonschema.validate(content, testsuite_schema_v2, resolver=resolver)
|
||||||
|
except jsonschema.exceptions.ValidationError as ex:
|
||||||
|
logger.log_error(str(ex))
|
||||||
|
raise exceptions.FileFormatError
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def is_testcase(data_structure):
|
def is_testcase(data_structure):
|
||||||
""" check if data_structure is a testcase.
|
""" check if data_structure is a testcase.
|
||||||
|
|||||||
Reference in New Issue
Block a user