字段优化
This commit is contained in:
parent
86d2bb3dc4
commit
15398493c1
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
@ -11,7 +11,7 @@ sys.path.append("../../common")
|
|||
from openpyxl import load_workbook
|
||||
from common.utils.decorators import singleton
|
||||
from common.file_handling import logger
|
||||
|
||||
from config.field_constants import FieldNames
|
||||
|
||||
@singleton
|
||||
class DoExcel:
|
||||
|
@ -19,7 +19,7 @@ class DoExcel:
|
|||
def __init__(self, file_name):
|
||||
self.file_name = file_name
|
||||
self.wb = load_workbook(self.file_name)
|
||||
self.init_sheet = self.wb["init"]
|
||||
self.init_sheet = self.wb[FieldNames.INIT]
|
||||
|
||||
# def __enter__(self):
|
||||
# self.wb = load_workbook(self.file_name)
|
||||
|
@ -42,7 +42,7 @@ class DoExcel:
|
|||
Returns:
|
||||
|
||||
"""
|
||||
sheets = eval(self.get_excel_init().get("Sheets"))
|
||||
sheets = eval(self.get_excel_init().get(FieldNames.SHEETS))
|
||||
for sheet_name in sheets:
|
||||
sheet = self.wb[sheet_name]
|
||||
max_row = self.get_max_row(sheet)
|
||||
|
@ -54,7 +54,7 @@ class DoExcel:
|
|||
sub_data = {}
|
||||
for k in range(1, max_column + 1):
|
||||
sub_data[first_header[k - 1]] = sheet.cell(i, k).value
|
||||
sub_data["Sheet"] = sheet_name
|
||||
sub_data[FieldNames.SHEET] = sheet_name
|
||||
yield sub_data
|
||||
|
||||
@logger.log_decorator()
|
||||
|
@ -69,9 +69,9 @@ class DoExcel:
|
|||
assert_log: 报错结果
|
||||
Returns:
|
||||
"""
|
||||
response = kwargs.get("response")
|
||||
result = kwargs.get("result")
|
||||
assertions = kwargs.get("assertions")
|
||||
response = kwargs.get(FieldNames.RESPONSE)
|
||||
result = kwargs.get(FieldNames.RESULT)
|
||||
assertions = kwargs.get(FieldNames.ASSERTIONS)
|
||||
sheet = self.wb[sheet_name]
|
||||
sheet.cell(i + 1, 24).value = response
|
||||
sheet.cell(i + 1, 25).value = result
|
||||
|
@ -85,7 +85,7 @@ class DoExcel:
|
|||
Returns:
|
||||
|
||||
"""
|
||||
sheets = eval(self.get_excel_init().get("Sheets"))
|
||||
sheets = eval(self.get_excel_init().get(FieldNames.SHEETS))
|
||||
|
||||
for sheet_name in sheets:
|
||||
sheet = self.wb[sheet_name]
|
||||
|
@ -112,7 +112,7 @@ class DoExcel:
|
|||
for k in range(2, max_row + 1):
|
||||
for i, v in enumerate(first_head):
|
||||
init[v] = self.init_sheet.cell(k, i + 1).value
|
||||
if init.get("Run").upper() == "YES":
|
||||
if init.get(FieldNames.RUN_CONDITION).upper() == FieldNames.YES:
|
||||
break
|
||||
return init
|
||||
|
||||
|
@ -126,10 +126,10 @@ class DoExcel:
|
|||
self.clear_date()
|
||||
test_case = self.do_excel_yield()
|
||||
init_data = self.get_excel_init()
|
||||
databases = init_data.get('Databases')
|
||||
initialize_data = eval(init_data.get("InitializeData"))
|
||||
host = init_data.get('Host', "")
|
||||
path = init_data.get("Path", "")
|
||||
databases = init_data.get(FieldNames.DATABASES)
|
||||
initialize_data = eval(init_data.get(FieldNames.INITIALIZE_DATA))
|
||||
host = init_data.get(FieldNames.HOST, "")
|
||||
path = init_data.get(FieldNames.PATH, "")
|
||||
host_path = host if host is not None else "" + path if path is not None else ""
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
|
Binary file not shown.
|
@ -177,8 +177,15 @@ class Action(Extractor, LoadScript, Validator):
|
|||
@staticmethod
|
||||
def is_run(condition):
|
||||
is_run = condition
|
||||
if not is_run or is_run.upper() != "YES":
|
||||
if not is_run or is_run.upper() != FieldNames.YES:
|
||||
return True
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def is_only_sql(method):
|
||||
if method.upper() == FieldNames.SQL:
|
||||
return True
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def pause_execution(sleep_time):
|
||||
|
|
Binary file not shown.
|
@ -11,6 +11,8 @@
|
|||
|
||||
class FieldNames:
|
||||
"""sheet字段"""
|
||||
INIT = "init"
|
||||
SHEETS = "Sheets"
|
||||
SHEET = "Sheet"
|
||||
ITEM_ID = "Id"
|
||||
RUN_CONDITION = "Run"
|
||||
|
@ -36,3 +38,11 @@ class FieldNames:
|
|||
SETUP_SCRIPT = "SetupScript"
|
||||
TEARDOWN_SCRIPT = "TeardownScript"
|
||||
PARAMS = "params"
|
||||
RESPONSE = "response"
|
||||
RESULT = "result"
|
||||
ASSERTIONS = "assertions"
|
||||
YES = "YES"
|
||||
DATABASES = "Databases"
|
||||
INITIALIZE_DATA = "InitializeData"
|
||||
HOST = "Host"
|
||||
PATH = "Path"
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -42,7 +42,7 @@ class TestProjectApi(unittest.TestCase):
|
|||
regex, keys, deps, jp_dict, ex_request_data = self.action.extractor_info(item)
|
||||
self.action.pause_execution(st)
|
||||
self.action.exc_sql(item)
|
||||
if method.upper() == 'SQL':
|
||||
if self.action.is_only_sql(method):
|
||||
self.skipTest("这条测试用例被 SQL 吃了,所以放弃执行了!!")
|
||||
# prepost_script = f"prepost_script_{sheet}_{iid}.py"
|
||||
# item = self.action.load_and_execute_script(Config.SCRIPTS_DIR, prepost_script, "setup", item)
|
||||
|
|
Loading…
Reference in New Issue