fix: json schema validation for testcase v2

This commit is contained in:
debugtalk
2019-12-31 19:18:47 +08:00
parent fffb2da7f6
commit 10974b5ad9
2 changed files with 13 additions and 11 deletions

View File

@@ -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)

View File

@@ -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.