mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
change: add json schema validation for testsuite v2
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
- feat: add json schema validation for api
|
||||
- feat: add json schema validation for testcase v2
|
||||
- feat: add json schema validation for testsuite
|
||||
- feat: add json schema validation for testsuite v2
|
||||
|
||||
**Changed**
|
||||
|
||||
|
||||
@@ -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")
|
||||
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_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:
|
||||
api_schema = json.load(f)
|
||||
@@ -22,8 +22,8 @@ with open(common_schema_path) as f:
|
||||
with open(testcase_schema_v2_path) as f:
|
||||
testcase_schema_v2 = json.load(f)
|
||||
|
||||
with open(testsuite_schema_path) as f:
|
||||
testsuite_schema = json.load(f)
|
||||
with open(testsuite_schema_v2_path) as f:
|
||||
testsuite_schema_v2 = json.load(f)
|
||||
|
||||
|
||||
class JsonSchemaChecker(object):
|
||||
@@ -42,7 +42,7 @@ class JsonSchemaChecker(object):
|
||||
@staticmethod
|
||||
def validate_testsuite_format(content):
|
||||
try:
|
||||
jsonschema.validate(content, testsuite_schema, resolver=resolver)
|
||||
jsonschema.validate(content, testsuite_schema_v2, resolver=resolver)
|
||||
except jsonschema.exceptions.ValidationError as ex:
|
||||
logger.log_error(str(ex))
|
||||
raise exceptions.FileFormatError
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "testsuite.schema.json#/definitions/testcase"
|
||||
"$ref": "testsuite.schema.v2.json#/definitions/testcase"
|
||||
}
|
||||
}
|
||||
},
|
||||
Reference in New Issue
Block a user