def test_02(self): # 添加新学生 Log().info("添加新学生") n = "21" json_data = [{ "userName": "******" + Funciton().randomnu + "", "realName": "zhengzhouxuesheng" + Funciton().randomnu + "", "nickName": "xuesheng" + Funciton().randomnu + "", "password": "******" }] current_time = time.strftime("%Y/%m/%d-%H:%M:%S") try: # 顺序依次:method、url、header、param(data) r = send_request( readExcel(Funciton().datainfo, self.sheetpage, "D" + n), Funciton().urltitle + readExcel(Funciton().datainfo, self.sheetpage, "E" + n), Funciton().header, json.dumps(json_data)) actual_result = r.status_code expected_results = int( readExcel(Funciton().datainfo, self.sheetpage, "G" + n)) Funciton().result_assertion(expected_results, actual_result, n) except: traceback.print_exc() finally: writeExcel(Funciton().datainfo, self.sheetpage, "J" + n, current_time)
def public_method(self, writenum): # 测试用例整体调用方法,readnum:rownum、current_time:获取当前时间 current_time = time.strftime("%Y/%m/%d-%H:%M:%S") # 读取excel整行数据 url = Body().test_url + self.request_info[4] header = Token().test_agent_header # 顺序依次:method、url、header、param(data) self.r = send_request(self.request_info[3], url, header, str(self.request_info[5])) writeExcel(self.datainfo, "J" + writenum, current_time) return self.r
def test_01(self): # 新增客户 Log().info("新增客户") n="8" json_data={"name":"吉一客户"+Funciton().randomnu,"nickName":"吉一客户","realName":"吉林一级客户","code":"j"+Funciton().randomnu+"","contact":"吉林一级客户","email":"*****@*****.**", "password":"******","confirmPwd":"111111","mobile":"13323132313","province":"22","city":"2201","district":"220102","address":"南关", "account":"jilin1j-"+Funciton().randomnu+"-"+Funciton().randomnu+"","schoolType": "7"} current_time = time.strftime("%Y/%m/%d-%H:%M:%S") try: # 顺序依次:method、url、header、param(data) r = send_request(readExcel(Funciton().datainfo,self.sheetpage, "D" + n), Funciton().urltitle + readExcel(Funciton().datainfo,self.sheetpage, "E" + n), Funciton().header, json.dumps(json_data)) actual_result = r.status_code expected_results = int(readExcel(Funciton().datainfo,self.sheetpage, "G" + n)) Funciton().result_assertion(expected_results,actual_result, n) except: traceback.print_exc() finally: writeExcel(Funciton().datainfo,self.sheetpage, "J" + n, current_time)
def public_method(self, n): # 测试用例整体调用方法,n:rownum、current_time:获取当前时间 current_time = time.strftime("%Y/%m/%d-%H:%M:%S") header = Token().uat_agent_header url = Body().uat_url + readExcel(self.datainfo, "E" + n) try: # 顺序依次:method、url、header、param(data) self.r = send_request(readExcel(self.datainfo, "D" + n), url, header, readExcel(self.datainfo, "F" + n)) actual_result = self.r.status_code expected_results = int(readExcel(self.datainfo, "G" + n)) self.result_assertion(expected_results, actual_result, n) self.assertEqual(int(readExcel(self.datainfo, "G" + n)), actual_result) except: traceback.print_exc() Log().info("Exception:" + self.r.json()['msg']) finally: writeExcel(self.datainfo, "J" + n, current_time)
def test_03(self): # 新增客户管理员 Log().info("新增客户管理员") n = "23" json_data = { "email": "", "password": "******", "confirmPwd": "111111", "mobile": "13323132313", "userName": "******" + Funciton().randomnu + "-" + Funciton().randomnu + "", "tenantId": 268, "realName": "吉一级管员" + Funciton().randomnu, "nickName": "吉管" + Funciton().randomnu } current_time = time.strftime("%Y/%m/%d-%H:%M:%S") try: # 顺序依次:method、url、header、param(data) r = send_request( readExcel(Funciton().datainfo, self.sheetpage, "D" + n), Funciton().urltitle + readExcel(Funciton().datainfo, self.sheetpage, "E" + n), Funciton().header, json.dumps(json_data)) actual_result = r.status_code expected_results = int( readExcel(Funciton().datainfo, self.sheetpage, "G" + n)) Funciton().result_assertion(expected_results, actual_result, n) except: traceback.print_exc() finally: writeExcel(Funciton().datainfo, self.sheetpage, "J" + n, current_time)