call HttpRunner class with testsets data structure other than path

This commit is contained in:
debugtalk
2018-04-17 21:41:02 +08:00
parent b6450afd0b
commit 37d9ea211f
5 changed files with 233 additions and 27 deletions

View File

@@ -417,6 +417,46 @@ def extend_test_api(test_block_dict):
test_extracors
)
def is_testset(data_structure):
""" check if data_structure is a testset
testset should always be in the following data structure:
{
"name": "desc1",
"config": {},
"api": {},
"testcases": [testcase11, testcase12]
}
"""
if not isinstance(data_structure, dict):
return False
if "name" not in data_structure or "testcases" not in data_structure:
return False
if not isinstance(data_structure["testcases"], list):
return False
return True
def is_testsets(data_structure):
""" check if data_structure is testset or testsets
testsets should always be in the following data structure:
testset_dict
or
[
testset_dict_1,
testset_dict_2
]
"""
if not isinstance(data_structure, list):
return is_testset(data_structure)
for item in data_structure:
if not is_testset(item):
return False
return True
def load_test_file(file_path):
""" load testset file, get testset data structure.
@param file_path: absolute valid testset file path
@@ -467,7 +507,9 @@ def load_test_file(file_path):
testset["api"][func_name] = api_info
else:
logger.log_warning("unexpected block: {}. block should only be config or test.".format(key))
logger.log_warning(
"unexpected block: {}. block should only be 'config', 'test' or 'api'.".format(key)
)
return testset