change: add json schema validation for testsuite v2

This commit is contained in:
debugtalk
2019-12-31 19:11:21 +08:00
parent 6d5943c0f3
commit fffb2da7f6
3 changed files with 6 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
- feat: add json schema validation for api - feat: add json schema validation for api
- feat: add json schema validation for testcase v2 - feat: add json schema validation for testcase v2
- feat: add json schema validation for testsuite - feat: add json schema validation for testsuite v2
**Changed** **Changed**

View File

@@ -10,7 +10,7 @@ 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_path = os.path.join(schemas_root_dir, "testsuite.schema.json") testsuite_schema_v2_path = os.path.join(schemas_root_dir, "testsuite.schema.v2.json")
with open(api_schema_path) as f: with open(api_schema_path) as f:
api_schema = json.load(f) api_schema = json.load(f)
@@ -22,8 +22,8 @@ with open(common_schema_path) as f:
with open(testcase_schema_v2_path) as f: with open(testcase_schema_v2_path) as f:
testcase_schema_v2 = json.load(f) testcase_schema_v2 = json.load(f)
with open(testsuite_schema_path) as f: with open(testsuite_schema_v2_path) as f:
testsuite_schema = json.load(f) testsuite_schema_v2 = json.load(f)
class JsonSchemaChecker(object): class JsonSchemaChecker(object):
@@ -42,7 +42,7 @@ class JsonSchemaChecker(object):
@staticmethod @staticmethod
def validate_testsuite_format(content): def validate_testsuite_format(content):
try: try:
jsonschema.validate(content, testsuite_schema, resolver=resolver) jsonschema.validate(content, testsuite_schema_v2, resolver=resolver)
except jsonschema.exceptions.ValidationError as ex: except jsonschema.exceptions.ValidationError as ex:
logger.log_error(str(ex)) logger.log_error(str(ex))
raise exceptions.FileFormatError raise exceptions.FileFormatError

View File

@@ -35,7 +35,7 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"items": { "items": {
"$ref": "testsuite.schema.json#/definitions/testcase" "$ref": "testsuite.schema.v2.json#/definitions/testcase"
} }
} }
}, },