def test03_trust_success(self):
     """开户"""
     #发送开户请求
     response = self.trust_api.trust_register(self.session)
     logging.info("trust respone = {}".format(response.json()))
     self.assertEqual(200,response.status_code)
     self.assertEqual(200,response.json().get("status"))
     #提取开户请求的响应中的HTML内容
     html_data = response.json().get("description").get("form")
     # #发送第三方请求
     response = third_party_request(self.session,html_data)
     logging.info('third request reposne = {}'.format(response.text))
     self.assertEqual(200,response.status_code)
     self.assertEqual('UserRegister OK',response.text)
 def test06_tender(self):
     #投资
     #发送投资请求
     amount = '100'
     response = self.tender_api.tender(self.session,self.tender_id,amount)
     logging.info("tender response = {}".format(response.json()))
     #断言投资结果是否正确
     self.assertEqual(200, response.status_code)
     self.assertEqual(200, response.json().get("status"))
     # 获取开户信息响应中的HTML内容(为后续请求的地址和参数)
     form_data = response.json().get("description").get("form")
     logging.info("form response={}".format(form_data))
     # 发送第三方的请求,请求第三方接口进行开户
     response = third_party_request(self.session,form_data)
     logging.info("third-interface response={}".format(response.text))
     # 断言第三方接口请求处理是否成功
     self.assertEqual('InitiativeTender OK', response.text)
Esempio n. 3
0
 def test02_recharge(self):
     #1、获取充值验证码
     response = self.trust_api.get_recharge_code(self.session)
     #logging.info('get_recharge_code_response = {}'.format(response.text))
     self.assertEqual(200, response.status_code)
     #2、充值(1000元)
     response = self.trust_api.recharge(self.session, '1000')
     logging.info('recharge response = {}'.format(response.json()))
     self.assertEqual(200, response.status_code)
     self.assertEqual(200, response.json().get("status"))
     #3、调用第三方充值接口
     #3.1获取充值响应中的HMTL数据
     html_data = response.json().get("description").get("form")
     #3.2提取第三方请求的URL和参数,并发送请求
     response = third_party_request(self.session, html_data)
     #3.5断言第三方请求是否成功
     self.assertEqual(200, response.status_code)
     self.assertEqual('NetSave OK', response.text)