def testGetAddressList(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('getAddressList') configHttp.set_url(self.url) print(self.url) # get token if self.token == '0': token = self.login_token else: token = self.token # set headers header = {"token": str(token)} configHttp.set_headers(header) # test interface self.return_json = configHttp.get() # check result self.checkResult()
def testRegisterQuick(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('registerQuick') localConfigHttp.set_url(self.url) # set header if self.token == '0': token = localReadConfig.get_headers("token_v") elif self.token == '1': token = None header = {'token': token} localConfigHttp.set_headers(header) # set params data = {'email': self.email} localConfigHttp.set_data(data) # test interface self.response = localConfigHttp.post() # check result self.checkResult()
def testUpdatePassword(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('updatePassword') localConfigHttp.set_url(self.url) # set header if self.token == '0': token = self.login_token elif self.token == '1': token = localReadConfig.get_headers("token_v") else: token = self.token header = {'token': token} localConfigHttp.set_headers(header) # set param data = { 'old_password': self.oldPwd, 'password': self.pwd, 'password_confirm': self.pwdConfirm } localConfigHttp.set_data(data) # test interface self.response = localConfigHttp.post() # check result self.checkResult()
def testGetAddressList(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('deleteAddress') configHttp.set_url(self.url) # get visitor token token = localReadConfig.get_headers("TOKEN_U") # set headers header = {"token": str(token)} configHttp.set_headers(header) # set params params = {"address_id": self.address_id} configHttp.set_params(params) # test interface self.return_json = configHttp.get() # check result self.checkResult()
def testGetProductInfo(self): """ test body :return: """ # set uel self.url = common.get_url_from_xml('productInfo') localConfigHttp.set_url(self.url) # set params if self.goodsId == '' or self.goodsId is None: params = None elif self.goodsId == 'null': params = {"goods_id": ""} else: params = {"goods_id": self.goodsId} localConfigHttp.set_params(params) # set headers if self.token == '' or self.token == 'null': cookie_token = localReadConfig.get_headers("cookie_v") else: cookie_token = localReadConfig.get_headers("tooken_v") headers = {"Cookie": "ASSIGNEE_JSESSIONID=" + str(cookie_token)} localConfigHttp.set_headers(headers) # get http self.response = localConfigHttp.get() # check result self.checkResult()
def testAccountSetting(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('accountSetting') localConfigHttp.set_url(self.url) # set header if self.token == '0': token = self.login_token else: token = self.token header = {'token': token} localConfigHttp.set_headers(header) # set param data = { 'sex': self.sex, 'telephone': self.telephone, 'nickname': self.nickname, 'birthday': self.birthday, 'country_id': self.countryId } localConfigHttp.set_data(data) # test interface self.response = localConfigHttp.post() # check result self.checkResult()
def testGenerate(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('generate') localConfigHttp.set_url(self.url) # test interface self.response = localConfigHttp.get() # check result self.checkResult()
def logout(token): """ logout :param token: login token :return: """ # set url url = common.get_url_from_xml('logout') localConfigHttp.set_url(url) # set header header = {'token': token} localConfigHttp.set_headers(header) # logout localConfigHttp.get()
def testAddAddress(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('addAddress') configHttp.set_url(self.url) # get token if self.token == '0': token = self.login_token elif self.token == '1': token = localReadConfig.get_headers("TOKEN_U") else: token = self.token # set headers header = {"token": str(token)} configHttp.set_headers(header) # set params data = { "sex": self.sex, "fname": self.fname, "lname": self.lname, "tel": self.tel, "standby_tel": self.standby_tel, "address1": self.address1, "address2": self.address2, "city": self.city, "state": self.state, "postcode": self.postcode, "country_id": self.country_id, "tax_number": self.tax_number, "company": self.company, "fax": self.fax, "is_default": self.is_default } configHttp.set_data(data) # test interface self.return_json = configHttp.post() # check result self.checkResult()
def testLoginFB(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('loginFb') localConfigHttp.set_url(self.url) # set header if self.token == '0': token = localReadConfig.get_headers("token_v") elif self.token == '1': token = None header = {'token': token} localConfigHttp.set_headers(header) # set params if self.invite_agency == '': self.invite_agency = int(0) data = {'email': self.email, 'facebook_id': self.facebook_id, 'fbtoken': self.fbtoken, 'invite_agency': self.invite_agency } localConfigHttp.set_data(data) # test interface if self.method == 'get': self.response = localConfigHttp.get() elif self.method == 'post': self.response = localConfigHttp.post() else: self.logger.info("No this interface's method:" + self.method) # check result self.checkResult()
def testLogout(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('logout') localConfigHttp.set_url(self.url) # set header if self.token == '0': token = self.login_token elif self.token == '1': token = localReadConfig.get_headers("token_v") else: token = self.token header = {'token': token} localConfigHttp.set_headers(header) # test interface self.response = localConfigHttp.get() # check result self.checkResult()
def testLogin(self): """ test body :return: """ # set url self.url = common.get_url_from_xml('login') configHttp.set_url(self.url) print("第一步:设置url " + self.url) # get visitor token if self.token == '0': token = localReadConfig.get_headers("token_v") elif self.token == '1': token = None # set headers header = {"token": str(token)} configHttp.set_headers(header) print("第二步:设置header(token等)") # set params data = {"email": self.email, "password": self.password} configHttp.set_data(data) print("第三步:设置发送请求的参数") # test interface self.return_json = configHttp.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("第五步:检查结果")