class GetData: def __init__(self): self.opera_excel = OperationExcel() #去获取excel行数,就是我们的case个数 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 != '': return header 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 #通过获取关键字拿到data数据 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_expcet_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_expcet_data_for_mysql(self, row): op_mysql = OperationMysql() sql = self.get_expcet_data(row) res = op_mysql.search_one(sql) return res.decode('unicode-escape') 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()) depent_key = self.opera_excel.get_content(row, col) if depent_key == "": return None else: return depent_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
class Getdata: def __init__(self): self.opera_excel = OperationExcel() self.get_data = global_var() # 获取Excel行数 def get_line(self): return self.opera_excel.get_lines() # 是否运行 def is_run(self, row): col = self.get_data.run run_model = self.opera_excel.get_content(row, int(col)) if run_model == "yes": flag = True else: flag = False return flag # 是否携带header def is_header(self, row): col = self.get_data.header header = self.opera_excel.get_content(row, int(col)) headers = json.dumps(header) if header == "": return None else: return headers # 获取请求方式 def run_way(self, row): col = self.get_data.request_way request_method = self.opera_excel.get_content(row, int(col)) return request_method # 获取url def get_url(self, row): col = self.get_data.url request_url = self.opera_excel.get_content(row, int(col)) return request_url # 获取请求数据 def get_request_data(self, row): col = self.get_data.data request_data = self.opera_excel.get_content(row, int(col)) if request_data == "": return None else: return request_data # 读取json文件中的数据 def get_data_for_json(self, row): # Opera_json = OperationJson('/Users/lyp/Desktop/jiekou/lover.json') Opera_json = OperationJson( "/Users/quanzi/Desktop/jiekou/love/lover.json") request_data_r = Opera_json.get_json_data(self.get_request_data(row)) if request_data_r == '': return None else: return request_data_r # 读取预期数据 def get_data_for_expect(self, row): col = self.get_data.expect expect_data = self.opera_excel.get_content(row, int(col)) if expect_data == '': return None else: return expect_data # 读取实际结果 def get_failed_results(self, row): col = self.get_data.result failed_result = self.opera_excel.get_content(row, int(col)) if failed_result == '': return None else: return failed_result # 读取case_tile结果 def get_case_Title(self, row): col = self.get_data.request_name case_Title = self.opera_excel.get_content(row, int(col)) if case_Title == '': return None else: return case_Title def write_result(self, row, value): col = self.get_data.get_result() self.opera_excel.write_value(row, int(col), value)