class DependentDate: def __init__(self, case_id): self.case_id = case_id self.opera_excel = OperationExcel() self.get_data = GetData() # 通过case_id去获取case_id的值 def get_case_line_data(self): rows_data = self.opera_excel.get_rows_data(self.case_id) return rows_data # 执行依赖测试,获取结果 def run_dependent(self): run_method = RunMethod() row_num = self.opera_excel.get_rows_data(self.case_id) print('111111', row_num, ) request_data = self.get_data.get_data_for_json(row_num) header = self.get_data.is_header(row_num) method = self.get_data.get_request_method(row_num) url = self.get_data.get_request_url(row_num) res = run_method.run_main(method, url, request_data, header) return res # 根据依赖值执行来测试case并返回 def get_data_for_key(self, row): depend_data = self.get_data.get_depend_key(row) print('2', depend_data) response_data = self.run_dependent() print('111', response_data) json_exe = parse(depend_data) madle = json_exe.find(response_data) return [math.value for math in madle][0]
def __init__(self, case_id): self.case_id = case_id self.opera_excel = OperationExcel() self.get_data = GetData()
def __init__(self): self.opera_excel = OperationExcel()
class GetData: def __init__(self): self.opera_excel = OperationExcel() # 获取excel行数() def get_case_lines(self): return self.opera_excel.get_lines() # 获取是否执行 def get_is_run(self, row): flag = None col = int(data_config.get_run()) run_model = self.opera_excel.get_cell_value(row, col) if run_model == 'yes': flag = True else: flag = False return flag # 是否携带header def is_header(self, row): col = int(data_config.get_header()) header = self.opera_excel.get_cell_value(row, col) if header == 'yes': return data_config.get_header_value() else: return None # 获取请求方式 def get_request_method(self, row): col = int(data_config.get_run_way()) request_method = self.opera_excel.get_cell_value(row, col) return request_method # 获取url def get_request_url(self, row): col = int(data_config.get_url()) url = self.opera_excel.get_cell_value(row, col) return url # 获取请求数据 def get_request_data(self, row): col = int(data_config.get_data()) data = self.opera_excel.get_cell_value(row, col) if data == '': return None return data # 获取json数据 def get_data_for_json(self, row): opera_json = OperationJson() request_data = opera_json.get_data(self.get_request_data(row)) return request_data # 获取预期结果 def get_expect_data(self, row): col = int(data_config.get_expect()) expect = self.opera_excel.get_cell_value(row, col) if expect == '': return None return expect # 通过SQL获取预期结果 def get_expect_data_for_mysql(self, row): op_mysql = OperationMysql() sql = self.get_expect_data(row) res = op_mysql.search_one(sql) return res # 写入结果 def write_result(self, row, value): col = int(data_config.get_result()) self.opera_excel.write_value(row, col, value) # 获取依赖数据的key def get_depend_key(self, row): col = int(data_config.get_data_depend()) depend_key = self.opera_excel.get_cell_value(row, col) if depend_key == "": return None else: return depend_key # 判断是否有case依赖 def is_depend(self, row): col = int(data_config.get_case_depend()) depend_case_id = self.opera_excel.get_cell_value(row, col) if depend_case_id == "": return None else: return depend_case_id # 获取数据依赖字段 def get_depend_field(self, row): col = int(data_config.get_field_depend()) data = self.opera_excel.get_cell_value(row, col) if data == "": return None else: return data