mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-08 17:29:34 +08:00
refactor: rename to JsonSchemaChecker
This commit is contained in:
@@ -2,7 +2,7 @@ import importlib
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from httprunner import exceptions, logger, utils
|
from httprunner import exceptions, logger, utils
|
||||||
from httprunner.loader.check import JsonSchemaCheck
|
from httprunner.loader.check import JsonSchemaChecker
|
||||||
from httprunner.loader.load import load_module_functions, load_file, load_dot_env_file, \
|
from httprunner.loader.load import load_module_functions, load_file, load_dot_env_file, \
|
||||||
load_folder_files
|
load_folder_files
|
||||||
from httprunner.loader.locate import init_project_working_directory, get_project_working_directory
|
from httprunner.loader.locate import init_project_working_directory, get_project_working_directory
|
||||||
@@ -357,7 +357,7 @@ def load_test_file(path):
|
|||||||
|
|
||||||
elif "request" in raw_content:
|
elif "request" in raw_content:
|
||||||
# file_type: api
|
# file_type: api
|
||||||
JsonSchemaCheck.check_api_format(raw_content)
|
JsonSchemaChecker.validate_api_format(raw_content)
|
||||||
loaded_content = raw_content
|
loaded_content = raw_content
|
||||||
loaded_content["path"] = path
|
loaded_content["path"] = path
|
||||||
loaded_content["type"] = "api"
|
loaded_content["type"] = "api"
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ with open(testsuite_schema_v2_path) as f:
|
|||||||
testsuite_schema_v2 = json.load(f)
|
testsuite_schema_v2 = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
class JsonSchemaCheck(object):
|
class JsonSchemaChecker(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_api_format(content):
|
def validate_api_format(content):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
jsonschema.validate(content, api_schema, resolver=resolver)
|
jsonschema.validate(content, api_schema, resolver=resolver)
|
||||||
@@ -40,14 +40,14 @@ class JsonSchemaCheck(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class JsonSchemaV1Check(JsonSchemaCheck):
|
class JsonSchemaV1Checker(JsonSchemaChecker):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class JsonSchemaV2Check(JsonSchemaCheck):
|
class JsonSchemaV2Checker(JsonSchemaChecker):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_testcase_format(content):
|
def validate_testcase_format(content):
|
||||||
""" check testcase format v2 if valid
|
""" check testcase format v2 if valid
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
@@ -59,7 +59,7 @@ class JsonSchemaV2Check(JsonSchemaCheck):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_testsuite_format(content):
|
def validate_testsuite_format(content):
|
||||||
try:
|
try:
|
||||||
jsonschema.validate(content, testsuite_schema_v2, resolver=resolver)
|
jsonschema.validate(content, testsuite_schema_v2, resolver=resolver)
|
||||||
except jsonschema.exceptions.ValidationError as ex:
|
except jsonschema.exceptions.ValidationError as ex:
|
||||||
|
|||||||
Reference in New Issue
Block a user