class Testpaymoney: def __init__(self): self.gs = Getsession() self.db = Operatdb() def test_paymoney(self, protocolname, caseid, casetitle, meth, url, data, exc): try: self.gs.login() # print(url) # 调用缴费接口 detail_record = data["student_name"] res, code = self.gs.reques_meth(meth, url, data) # 数据库查询 sql = f'SELECT * FROM finance_detail WHERE expend_name="{detail_record}";' li, num = self.db.read_db(sql) # print(res,exc) # print(num) if code == 200 and exc == res and num == 1: print("测试成功") self.db.insert_res(protocolname, caseid, casetitle, "success", "无") else: print("测试失败") self.db.insert_res(protocolname, caseid, casetitle, "failed", "无") except Exception as e: self.db.insert_res(protocolname, caseid, casetitle, "error", e)
class Testupload: def __init__(self): self.gs = Getsession() self.da = Getdata() def test_upload(self, protocolname, caseid, casetitle, meth, url, data, exc): file = data["token"] data.pop("token") db = Operatdb() try: self.gs.login() if file != "": fil = { "batchfile": ("Asdf.xls", open(rf"{file}", mode="rb").read()) } # print(data,fil) # 构建数据 与 数据库查询出来的作对比 else: fil = "" li = self.da.get_model_data(0, file) res, code = self.gs.reques_meth(meth, url, data, fil) print(res, code) li1 = [] dic = {} dic.update({ "age": str(int(li[0]["年龄"])), "sex": li[0]["性别"], "email": li[0]["电子邮件"], "school": li[0]["学校名称"] }) li1.append(dic) mail = li1[0]["email"] print(mail) # 数据库查询 sql = f'SELECT age,sex,email,school FROM customer WHERE email="{mail}";' # 得到数据库查询结果 dbli, num = db.read_db(sql) # print(code==200) # print(li1==dbli) # print(li1) # print(dbli) # print(exc==res) # 断言 if code == 200 and exc == res and li1 == dbli: print("测试成功") db.insert_res(protocolname, caseid, casetitle, "success", "无") else: print("测试失败") db.insert_res(protocolname, caseid, casetitle, "failed", "无") except Exception as e: print(e) db.insert_res(protocolname, caseid, casetitle, "error", "出错了")
class Testsearchfin: def __init__(self): self.gs = Getsession() self.db = Operatdb() def test_searchfinance(self,protocolname, caseid, casetitle,meth,url,data,exc): # 登录 self.gs.login() # 调用解密接口----不然查询结果含**** ur = "http://localhost:8080/WoniuBoss3.5/second" da = {"vp": "woniu123"} self.gs.reques_meth("post", ur, da) res, code = self.gs.reques_meth(meth, url, data) # print(res) # 查询数据库 if code == 200 and exc == res: print("测试成功") self.db.insert_res(protocolname, caseid, casetitle, "success", "无") else: print("测试失败") self.db.insert_res(protocolname, caseid, casetitle, "failed", "无")
class TestLogin: def __init__(self): self.gs=Getsession() self.db=Operatdb() def test_login(self,protocolname,caseid,casetitle,meth,url,data,exc): res,code=self.gs.reques_meth(meth,url,data) print(res,code) if code==200 and exc in res: print("测试通过") self.db.insert_res(protocolname,caseid,casetitle,"success","无") else: print("测试失败") self.db.insert_res(protocolname, caseid, casetitle, "failed", "无")
class Testsafe: def __init__(self): self.gs = Getsession() self.db = Operatdb() def test_safe(self, protocolname, caseid, casetitle, meth, url, data, exc): self.gs.login("wncd123", "woniu123") res, code = self.gs.reques_meth(meth, url, data) # print(res) if code == 200 and exc in res: print("测试成功") self.db.insert_res(protocolname, caseid, casetitle, "success", "无") else: print("测试失败") self.db.insert_res(protocolname, caseid, casetitle, "failed", "无")
class Testdecioher: def __init__(self): self.gs=Getsession() self.db = Operatdb() # 测试 def test_decipher(self,protocolname,caseid,casetitle,meth,url,data,exc): self.gs.login() print(data) res,code=self.gs.reques_meth(meth,url,data) print(res,code) if code==200 and exc==res: print("测试成功") self.db.insert_res(protocolname, caseid, casetitle, "success", "无") else: print("测试失败") self.db.insert_res(protocolname, caseid, casetitle, "failed", "无")
class Testtracksrc: def __init__(self): self.gs = Getsession() self.db = Operatdb() # 测试 def test_tracksrc(self,protocolname, caseid, casetitle,meth,url,data,exc): try: self.gs.login() # print(url) # 调用资源跟踪接口 res, code = self.gs.reques_meth(meth, url, data) # print(res, code) # 数据库断言 ids=data["id"] sql="SELECT " \ "cus.last_status 'status'," \ "stu.need_fee fee," \ "cus.last_tracking_remark remark," \ "cus.customer_id id," \ "cus.next_tracking_time nextTime," \ "cus.priority priority " \ "FROM " \ "customer cus,student stu " \ "WHERE " \ "stu.student_customer_id = cus.customer_id " \ f"AND cus.customer_id = '{ids}' ;" li,num=self.db.read_db(sql) print(li) # 3个条件断言 if code == 200 and exc == res and li[0]==data: print("测试成功") self.db.insert_res(protocolname, caseid, casetitle, "success", "无") else: print("测试失败") self.db.insert_res(protocolname, caseid, casetitle, "failed", "无") except Exception as e: self.db.insert_res(protocolname, caseid, casetitle, "error", e)