def __init__(self, txt_path=None, report_path=None, excelpath=None, jsonpath=None): if report_path: self.report_path = report_path else: self.report_path = "../Test_Case/Report.html" if txt_path: self.txt_path = txt_path else: self.txt_path = "../Test_Case/Result.txt" if jsonpath: self.jsonpath = jsonpath else: self.jsonpath = "../Test_Case/TestCase.xls" self.run_method = inter() self.data = Getdata(excelpath=excelpath, jsonfilepath=jsonpath) self.result = isequal() self.opexcel = oper_excel(filename=excelpath) self.sendmail = sendmail() self.page_check = PageCheck() self.de_data = dependata(excelpath=excelpath, jsonpath=jsonpath) self.pass_total = [] self.fail_total = []
def __init__(self,excelpath= None,jsonpath=None): if excelpath: self.excelpath = excelpath else: self.excelpath = '../Test_Case/TestCase.xls' if jsonpath: self.jsonpath = jsonpath else: self.jsonpath='..//data//Tc_alldata.json' self.get = Getdata(self.excelpath,self.jsonpath) self.operation_excel = oper_excel(self.excelpath)
def __init__(self,division= None,classname = None): # 若传参:属性标签以及数据排序方式 if division and classname: self.division = division self.classname = classname #不传参,默认表格数据,div,x-scroll else: self.division = "div" self.classname = "x-scroll" self.data = Getdata() self.cookies = Get_cookies.Get_cookies(2) self.cookies= self.cookies.get_cookies_admin()
def __init__(self, filename=None, new_filename=None, report_path=None): self.tablename = Case_Table().get_tablename() if filename: self.filename = filename else: self.filename = "../Test_Case/" + self.tablename + ".xls" if new_filename: self.new_filename = new_filename else: self.new_filename = "../Test_Case/" + self.tablename + "_bk.xls" if report_path: self.report_path = report_path else: self.report_path = "../Test_Case/TestCase.html" self.data = Getdata()
def __init__(self, excelpath=None, jsonpath=None): self.tablename = Case_Table().get_tablename() if excelpath: self.excelpath = excelpath else: self.excelpath = "../Test_Case/" + self.tablename + ".xls" if jsonpath: self.jsonpath = jsonpath else: self.jsonpath = "../data/" + self.tablename + ".json" self.run_method = inter() self.data = Getdata(self.excelpath, self.jsonpath) self.result = isequal() self.sendmail = sendmail() self.page_check = PageCheck() self.de_data = dependata(self.excelpath, self.jsonpath) self.caserun = Case(excelpath=self.excelpath, jsonpath=self.jsonpath) self.opexcel = oper_excel(filename=excelpath) self.DBCASE = Get_case()
def __init__(self): self.excelpath= "../Test_Case/Paper_Process.xls" self.db,self.connect = DB_CONNECT(2).connect_db() self.excel = oper_excel(filename="../Test_Case/Paper_Process.xls") self.data = Getdata(excelpath=self.excelpath)
def isequalstring(self, expect, result,i): # expect是预期结果一栏中数据,若是None则不做比较 if expect == None: print("无预期结果,接口不做比较") return True # expect是预期结果一栏中数据,若是Select,则执行sql语句 elif expect.startswith("select"): print("select",expect) db = DataBase() # 执行sql获取返回结果sql_value sql_value = db.selectvalue(expect) # expect_compare:获取case表格中sql比对结果的值 ex = Getdata() expect_compare = ex.get_db_value(i) if sql_value == [None]: # print("数据*****", sql_value, type(sql_value),expect_compare) if expect_compare == None: print("数据删除成功,数据库无数据") return True else: print("数据库数据不存在,请检查") return False else: try: expect_compare_len = len(expect_compare) sql_value_len = len(sql_value) except Exception as e: # print("whywhy",expect_compare,sql_value) print("请检查是否数据库链接错误,没有查到数据",expect_compare,sql_value) # sql执行结果与预期比较数据中查找共同字段,且比较值是否相等 # 借助辅助数组 compare_dict = {} for i in range(len(sql_value)): # print("数据*****",sql_value[i],type(sql_value[i])) for k in sql_value[i]: try: if k in expect_compare: #相同值添加至辅助数组 compare_dict[k] = expect_compare.get(k) except Exception as e: print("没有找到expect",expect_compare,"sql_value",sql_value,"coppare_dict",compare_dict) # print("数据*****",compare_dict,type(compare_dict),compare_dict,sql_value,sql_value==compare_dict) # 辅助数组与sql查询数组比较 if operator.eq(compare_dict,sql_value[i]): #sql查询结果与预期比较结果一致 return True else: # print("sql查询数据与预期结果不相等",sql_value,"!=",expect_compare) return False else: # expect是预期结果一栏中数据,若是指定字符,则与请求响应结果比较 if isinstance(result,dict): result = str(result) if expect in result: return True else: return False elif str(result)== expect: return True return False # a = isequal() # # expect = "select activityId,seasonId,uid from ActivitySeasonUser where seasonId =835 ORDER BY id DESC LIMIT 1" # # result = { # # "activityId": 740, # # "seasonId": 835, # # "uid": 18213 # # } # expect = "<Response [302]>" # result ="<Response [302]>" # print(a.isequalstring(expect,expect,3))
def __init__(self, excelpath, file_path): self.data = Getdata(excelpath=excelpath) self.opexcel = oper_excel(filename=excelpath) self.file_path = file_path