change: remove format v2 symbol

This commit is contained in:
debugtalk
2020-04-09 11:15:54 +08:00
parent 456e966570
commit d98fbc8da7
4 changed files with 20 additions and 20 deletions

View File

@@ -80,7 +80,7 @@ def __extend_with_testcase_ref(raw_testinfo):
# TODO: validate with pydantic
if isinstance(loaded_testcase, dict) and "teststeps" in loaded_testcase:
testcase_dict = load_testcase_v2(loaded_testcase)
testcase_dict = load_testcase(loaded_testcase)
else:
raise exceptions.FileFormatError(
f"Invalid format testcase: {testcase_path}")
@@ -144,8 +144,8 @@ def load_teststep(raw_testinfo):
return raw_testinfo
def load_testcase_v2(raw_testcase):
""" load testcase in format version 2.
def load_testcase(raw_testcase):
""" load testcase.
Args:
raw_testcase (dict): raw testcase content loaded from JSON/YAML file:
@@ -174,7 +174,7 @@ def load_testcase_v2(raw_testcase):
}
"""
JsonSchemaChecker.validate_testcase_v2_format(raw_testcase)
JsonSchemaChecker.validate_testcase_format(raw_testcase)
raw_teststeps = raw_testcase.pop("teststeps")
raw_testcase["teststeps"] = [
load_teststep(teststep)
@@ -220,7 +220,7 @@ def load_testsuite(raw_testsuite):
# invalid format
raise exceptions.FileFormatError("Invalid testsuite format!")
JsonSchemaChecker.validate_testsuite_v2_format(raw_testsuite)
JsonSchemaChecker.validate_testsuite_format(raw_testsuite)
raw_testsuite["testcases"] = {}
for raw_testcase in raw_testcases:
__extend_with_testcase_ref(raw_testcase)
@@ -278,7 +278,7 @@ def load_test_file(path: str) -> dict:
elif "teststeps" in raw_content:
# file_type: testcase (format version 2)
loaded_content = load_testcase_v2(raw_content)
loaded_content = load_testcase(raw_content)
loaded_content["path"] = path
loaded_content["type"] = "testcase"

View File

@@ -11,8 +11,8 @@ from httprunner import exceptions
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_v2_path = os.path.join(schemas_root_dir, "testsuite.schema.v2.json")
testcase_schema_path = os.path.join(schemas_root_dir, "testcase.schema.json")
testsuite_schema_path = os.path.join(schemas_root_dir, "testsuite.schema.json")
with io.open(api_schema_path, encoding='utf-8') as f:
api_schema = json.load(f)
@@ -27,11 +27,11 @@ with io.open(common_schema_path, encoding='utf-8') as f:
common_schema = json.load(f)
resolver = jsonschema.RefResolver(absolute_base_path, common_schema)
with io.open(testcase_schema_v2_path, encoding='utf-8') as f:
testcase_schema_v2 = json.load(f)
with io.open(testcase_schema_path, encoding='utf-8') as f:
testcase_schema = json.load(f)
with io.open(testsuite_schema_v2_path, encoding='utf-8') as f:
testsuite_schema_v2 = json.load(f)
with io.open(testsuite_schema_path, encoding='utf-8') as f:
testsuite_schema = json.load(f)
class JsonSchemaChecker(object):
@@ -55,16 +55,16 @@ class JsonSchemaChecker(object):
return JsonSchemaChecker.validate_format(content, api_schema)
@staticmethod
def validate_testcase_v2_format(content):
""" check testcase format v2 if valid
def validate_testcase_format(content):
""" check testcase format if valid
"""
return JsonSchemaChecker.validate_format(content, testcase_schema_v2)
return JsonSchemaChecker.validate_format(content, testcase_schema)
@staticmethod
def validate_testsuite_v2_format(content):
""" check testsuite format v2 if valid
def validate_testsuite_format(content):
""" check testsuite format if valid
"""
return JsonSchemaChecker.validate_format(content, testsuite_schema_v2)
return JsonSchemaChecker.validate_format(content, testsuite_schema)
def is_test_path(path):
@@ -150,7 +150,7 @@ def is_test_content(data_structure):
for item in testcases:
is_testcase = False
try:
JsonSchemaChecker.validate_testcase_v2_format(item)
JsonSchemaChecker.validate_testcase_format(item)
is_testcase = True
except exceptions.FileFormatError:
pass
@@ -169,7 +169,7 @@ def is_test_content(data_structure):
for item in testsuites:
is_testcase = False
try:
JsonSchemaChecker.validate_testsuite_v2_format(item)
JsonSchemaChecker.validate_testsuite_format(item)
is_testcase = True
except exceptions.FileFormatError:
pass