def testGetAddressList(self): """ test body :return: """ # set url self.url = comm.get_url_from_xml('getAddress') configHttp.set_url(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) # set params params = {"address_id": self.address_id} configHttp.set_params(params) # test interface self.return_json = configHttp.get() # check result self.checkResult()
def testUpdatePassword(self): """ test body :return: """ # set url self.url = comm.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 testAccountSetting(self): """ test body :return: """ # set url self.url = comm.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 testGetAddressList(self): """ test body :return: """ # set url self.url = comm.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 url self.url = comm.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 == '0': token = localReadConfig.get_headers("token_v") else: token = self.token headers = {"token": str(token)} localConfigHttp.set_headers(headers) # get http self.response = localConfigHttp.get() # check result self.checkResult()
def testGetGuest(self): """ test body :return: 1.参数准备 2.发送请求 3.断言 """ # set url url = comm.get_url_from_xml('guest_get') localConfigHttp.set_url(url) # set params if (self.eid == '') and (self.phone_query == ''): params = None print("phone和eid为空!") elif self.eid != '' and self.phone_query == '': params = {"eid": self.eid} print("params为eid!") elif self.eid == '' and self.phone_query != '': params = {"name": self.phone_query} print("params为name!") elif self.eid != '' and self.phone_query != '': params = {"eid": self.eid, "phone": self.phone_query} print("phone和eid都有值,联合查询!!") else: print("set params error!") localConfigHttp.set_params(params) # 发送get请求 self.response = localConfigHttp.get() # 断言结果 self.checkResult()
def testUploadImg(self): """ test body :return: """ # set url self.url = comm.get_url_from_xml('uploadImg') 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 files localConfigHttp.set_files(self.file) # set data data = {'whole': self.whole} localConfigHttp.set_data(data) # test interface self.response = localConfigHttp.postWithFile() # check result self.checkResult()
def testRegisterQuick(self): """ test body :return: """ # set url self.url = comm.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 logout(token): """ logout :param token: login token :return: """ # set url url = comm.get_url_from_xml('logout') localConfigHttp.set_url(url) # set header header = {'token': token} localConfigHttp.set_headers(header)
def testGenerate(self): """ test body :return: """ # set url self.url = comm.get_url_from_xml('generate') localConfigHttp.set_url(self.url) # test interface self.response = localConfigHttp.get() # check result self.checkResult()
def login(): """ login :return: token """ # set url url = comm.get_url_from_xml('login') localConfigHttp.set_url(url) # set header token = localReadConfig.get_headers("token_v") header = {"token": token} localConfigHttp.set_headers(header) # set data data = {"email": localLogin_xls[0][3], "password": localLogin_xls[0][4]} localConfigHttp.set_data(data)
def testAddAddress(self): """ test body :return: """ # set url self.url = comm.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 testAddGuest(self): """ test body :return: 1.参数准备 2.发送请求 3.断言 """ # set url self.url = comm.get_url_from_xml('user_sign') # 2.修改URL读取文件 localConfigHttp.set_url(self.url) # set data data = {'eid': self.eid, 'phone': self.phone} localConfigHttp.set_data(data) # 发送get请求 if self.method == 'post': self.response = localConfigHttp.postData() else: print("请确认是请求方式:POST or GET?") # 断言结果 self.checkResult()
def testAddGuest(self): """ test body :return: 1.参数准备 2.发送请求 3.断言 """ # set url self.url = comm.get_url_from_xml('guest_add') # 2.修改URL读取文件 localConfigHttp.set_url(self.url) # set data data = { 'eid': self.eid, 'realname': self.realname, 'phone': self.phone } localConfigHttp.set_data(data) # 发送get请求 self.response = localConfigHttp.postData() # 断言结果 self.checkResult()
def testLoginFB(self): """ test body :return: """ # set url self.url = comm.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 testLogin(self): """ test body :return: """ # set url self.url = comm.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("第五步:检查结果")
def testLogout(self): """ test body :return: """ # set url self.url = comm.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()