def testLogout(self): """ test body :return: """ print("开始执行用例====================>>>>") # get url self.url = common.get_url_from_xml('logout') configHttp.set_url(self.url) print("第一步:设置url " + self.url) # get visitor token if self.token == '1': token = self.user_token elif self.token == '0': token = None # set headers header = {"authorization": token, "Content-Type": "application/json"} configHttp.set_headers(header) print("第二步:设置header(token等)") # set params body = {"unbind": self.unbind} configHttp.set_data(body) print("第三步:设置发送请求的参数", body) # test interface print("第四步:发送请求请求方法:") self.return_json = configHttp.postWithJson() # check result print("第五步:检查结果") self.checkResult()
def testSendVerifyCode(self): """ test body :return: """ print("开始执行用例====================>>>>") # get url self.url = common.get_url_from_xml('sendVerifyCode') configHttp.set_url(self.url) print("第一步:设置url " + self.url) # get visitor token if self.token == '1': token = localReadConfig.get_headers("token_v") elif self.token == '0': token = None # set headers header = {"Content-Type": "application/json"} configHttp.set_headers(header) print("第二步:设置header(token等)") # set params body = {"mobile": self.mobile} configHttp.set_data(body) print("第三步:设置发送请求的参数", body) # test interface print("第四步:发送请求请求方法:") self.return_json = configHttp.postWithJson() # check result print("第五步:检查结果") self.checkResult()
def send_verify_code(mobile): url = common.get_url_from_xml('sendVerifyCode') configHttp.set_url(url) header = {"Content-Type": "application/json"} configHttp.set_headers(header) body = {"mobile": mobile} configHttp.set_data(body) return_json = configHttp.postWithJson() return return_json.json()
def logout(token): url = common.get_url_from_xml('logout') configHttp.set_url(url) header = {"authorization": token, "Content-Type": "application/json"} configHttp.set_headers(header) body = {"unbind": 'true'} configHttp.set_data(body) return_json = configHttp.postWithJson() return return_json
def check_verify_code(mobile, mobile_code): url = common.get_url_from_xml('checkVerifyCode') configHttp.set_url(url) header = {"Content-Type": "application/json"} configHttp.set_headers(header) body = {"mobile": mobile, "code": mobile_code} configHttp.set_data(body) return_json = configHttp.postWithJson() return return_json.json()['data']['token']
def testrealface(self): """ test body :return: """ # set url # self.url = "/api/front/real-name-test" self.url = common.get_url_from_xml('realface') configHttp.set_url(self.url) print("第一步:设置url " + self.url) # get visitor token if self.token == '0': token = str(self.login_token) else: token = None # print(token) token1 = "Bearer " + str(token) # print(token1) header = { "Content-Type": "application/json", "Authorization": str(token1) } configHttp.set_headers(header) print("第二步:设置header(token等)") self.photo_id = businessCommon.upload(1) print("#######" + self.photo_id) data = { "realname": self.realname, "idcard": self.idcard, "photoId": self.photo_id } configHttp.set_data(data) print("第三步:设置发送请求的参数") # test interface self.return_json = configHttp.postWithJson() print(self.return_json) # 返回<Response [200]> print(self.return_json.request) # <PreparedRequest [POST]> method = str(self.return_json.request )[int(str(self.return_json.request).find('[')) + 1:int(str(self.return_json.request).find(']'))] print("第四步:发送请求\n\t\t请求方法:" + method) # check result self.checkResult() print("第五步:检查结果")
def testrealname(self): """ test body :return: """ # set url # self.url = "/api/front/real-name-test" self.url = common.get_url_from_xml('realname') configHttp.set_url(self.url) print("第一步:设置url " + self.url) # get visitor token if self.token == '1': token = None else: token = localReadConfig.get_headers("Authorization") # header = {'Authorization': "Bearer " + str(token)} # configHttp.set_headers(header) token1 = "Bearer" + str(token) print("当前token**:" + token1) # set headers header = { "Content-Type": "application/json", "Authorization": str(token1) } configHttp.set_headers(header) print("第二步:设置header(token等)") # set params data = {"realname": self.realname, "idcard": self.idcard} configHttp.set_data(data) print("第三步:设置发送请求的参数") # test interface self.return_json = configHttp.postWithJson() print(self.return_json) # 返回<Response [200]> print(self.return_json.request) # <PreparedRequest [POST]> method = str(self.return_json.request )[int(str(self.return_json.request).find('[')) + 1:int(str(self.return_json.request).find(']'))] print("第四步:发送请求\n\t\t请求方法:" + method) # check result self.checkResult() print("第五步:检查结果")