mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +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_testsuite["testcases"] = {}
|
||||
|
||||
@@ -293,6 +292,7 @@ def load_testsuite(raw_testsuite):
|
||||
raw_testsuite["testcases"][name] = raw_testcase
|
||||
|
||||
elif isinstance(raw_testcases, list):
|
||||
JsonSchemaChecker.validate_testsuite_v2_format(raw_testsuite)
|
||||
# format version 2, implemented in 2.2.0
|
||||
for raw_testcase in raw_testcases:
|
||||
__extend_with_testcase_ref(raw_testcase)
|
||||
|
||||
@@ -39,16 +39,6 @@ class JsonSchemaChecker(object):
|
||||
|
||||
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
|
||||
def validate_testcase_v1_format(content):
|
||||
""" check testcase format v1 if valid
|
||||
@@ -67,6 +57,18 @@ class JsonSchemaChecker(object):
|
||||
|
||||
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):
|
||||
""" check if data_structure is a testcase.
|
||||
|
||||
Reference in New Issue
Block a user