rename functions

This commit is contained in:
debugtalk
2017-09-22 14:31:23 +08:00
parent bcd879db99
commit 8d2d52b192
8 changed files with 37 additions and 38 deletions

View File

@@ -22,5 +22,4 @@ class WebPageUser(HttpLocust):
min_wait = 1000
max_wait = 5000
testsets = testcase.load_testcases_by_path("$TESTCASE_FILE")
testset = testsets[0]
testset = testcase.load_test_file("$TESTCASE_FILE")

View File

@@ -3,7 +3,7 @@ import multiprocessing
import os
import sys
from ate.testcase import load_testcases_by_path
from ate.testcase import load_test_file
from locust.main import main
@@ -36,8 +36,8 @@ def gen_locustfile(testcase_file_path):
os.path.dirname(os.path.realpath(__file__)),
'locustfile_template'
)
testsets = load_testcases_by_path(testcase_file_path)
host = testsets[0].get("config", {}).get("request", {}).get("base_url", "")
testset = load_test_file(testcase_file_path)
host = testset.get("config", {}).get("request", {}).get("base_url", "")
with codecs.open(template_path, encoding='utf-8') as template:
with codecs.open(locustfile_path, 'w', encoding='utf-8') as locustfile:

View File

@@ -117,8 +117,11 @@ def load_testcases_by_path(path):
return load_testcases_by_path(files_list)
elif os.path.isfile(path):
return load_test_file(path)
testset = load_test_file(path)
if testset["testcases"] or testset["api"]:
return [testset]
else:
return []
else:
return []
@@ -141,9 +144,9 @@ def load_test_file(file_path):
"api": {},
"testcases": []
}
testcases_list = utils.load_testcases(file_path)
tests_list = utils.load_tests(file_path)
for item in testcases_list:
for item in tests_list:
for key in item:
if key == "config":
testset["config"].update(item["config"])
@@ -170,10 +173,7 @@ def load_test_file(file_path):
api_info.update(item["api"])
testset["api"][func_name] = api_info
if testset["testcases"] or testset["api"]:
return [testset]
else:
return []
return testset
def load_testcases_by_call(test_block_dict, call_type):
call_func = test_block_dict[call_type]

View File

@@ -49,7 +49,7 @@ def load_json_file(json_file):
with codecs.open(json_file, encoding='utf-8') as data_file:
return json.load(data_file)
def load_testcases(testcase_file_path):
def load_tests(testcase_file_path):
file_suffix = os.path.splitext(testcase_file_path)[1]
if file_suffix == '.json':
return load_json_file(testcase_file_path)