def test_search_api(self): self.infoma["id"] = self.param["id"] self.infoma["casename"] = self.param["casename"] util.DATA["sum"] = util.DATA["sum"] + 1 self.response = req.reqData(req, url=self.param["api"], datas=self.param["data"]) baseCheck = self.searchCases["Check"] try: if self.response["c"] == baseCheck["c"] and self.response[ "m"] == baseCheck["m"] and self.response[ "ok"] == baseCheck["ok"]: util.DATA["pass"] = util.DATA["pass"] + 1 self.infoma["result"] = "通过" self.writeLog(self.param["casename"], flag=True, result="通过") else: util.DATA["fail"] = util.DATA["fail"] + 1 self.infoma["result"] = "失败" # self.infoma["reason"] = "断言预期与实际不符" self.infoma["reason"] = self.response["m"] self.writeLog(self.param["casename"], flag=False, result="失败" + self.response["m"]) except: util.DATA["fail"] = util.DATA["fail"] + 1 self.infoma["result"] = "失败" self.infoma["reason"] = self.response["message"] self.writeLog(self.param["casename"], flag=False, result="异常" + self.response["message"]) util.INFO.append(self.infoma)
def setUp(self): login = req.reqData(req) self.infoma = {} self.response = "" self.infoma["id"] = x["testinfo"][0]["id"] self.infoma["module"] = x["testinfo"][0]["module"] self.infoma["intr"] = x["testinfo"][0]["intr"]
def test_home_api(self): self.response = req.reqData(req, url=self.param["api"], datas=self.param["data"]) baseCheck = getHomeCases["basecheck"] if self.response["c"] == baseCheck["c"] and self.response["m"]: util.DATA["pass"] = util.DATA["pass"] + 1 self.infoma["result"] = "通过" self.infoma["reason"] = self.response["m"] else: util.DATA["fail"] = util.DATA["fail"] + 1 self.infoma["result"] = "失败" # self.infoma["reason"] = "断言预期与实际不符" self.infoma["reason"] = self.response["m"] self.infoma["casename"] = self.param["casename"] util.DATA["sum"] = util.DATA["sum"] + 1 util.INFO.append(self.infoma)
def test_user_api(self): self.infoma["id"] = self.param["id"] self.infoma["casename"] = self.param["casename"] util.DATA["sum"] = util.DATA["sum"] + 1 self.response = req.reqData(req, url=self.param["api"], datas=self.param["data"]) baseCheck = self.userAPI["Check"] try: if self.response["c"] == baseCheck["c"] and self.response["m"] == baseCheck["m"] and self.response["ok"] == \ baseCheck["ok"]: util.DATA["pass"] = util.DATA["pass"] + 1 self.infoma["result"] = "通过" else: util.DATA["fail"] = util.DATA["fail"] + 1 self.infoma["result"] = "失败" self.infoma["reason"] = self.response["m"] except: util.DATA["fail"] = util.DATA["fail"] + 1 self.infoma["result"] = "失败" self.infoma["reason"] = self.response["message"] util.INFO.append(self.infoma)