示例#1
0
 def test02_recharge(self):
     #1、登录成功
     # 1、认证通过的账号登录
     response = self.login_api.login(self.session)
     logging.info("login response = {}".format(response.json()))
     assert_utils(self, response, 200, 200, "登录成功")
     #2、 获取充值验证码
     r = random()
     response = self.trust_api.get_recharge_verify_code(
         self.session, str(r))
     logging.info("get recharge verify code reponse = {}".format(
         response.text))
     self.assertEqual(200, response.status_code)
     #3、 发送充值请求
     response = self.trust_api.recharge(self.session, '10000')
     logging.info("recharge response = {}".format(response.json()))
     self.assertEqual(200, response.status_code)
     self.assertEqual(200, response.json().get("status"))
     #4、 发送第三方充值请求
     # 获取响应中form表单的数据,并提取为后续第三方请求的参数
     form_data = response.json().get("description").get("form")
     logging.info('form response={}'.format(form_data))
     # 调用第三方请求的接口
     response = request_third_api(form_data)
     logging.info('third recharge response={}'.format(form_data))
     #断言response是否正确
     self.assertEqual('NetSave OK', response.text)
 def test03_trust_success(self):
     """开户"""
     #获取开户信息
     response = self.trust_api.trust_register(self.session)
     logging.info("trust 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 = request_third_api(form_data)
     logging.info("third-interface response={}".format(response.text))
     #断言第三方接口请求处理是否成功
     self.assertEqual('UserRegister OK',response.text)
示例#3
0
 def test02_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 = request_third_api(form_data)
     logging.info("third-interface response={}".format(response.text))
     # 断言第三方接口请求处理是否成功
     self.assertEqual('InitiativeTender OK', response.text)
示例#4
0
 def test01_trust_request(self):
     # 1、认证通过的账号登录
     response = self.login_api.login(self.session)
     logging.info("login response = {}".format(response.json()))
     assert_utils(self, response, 200, 200, "登录成功")
     #2、 发送开户请求
     response = self.trust_api.trust_register(self.session)
     logging.info("trust register response = {}".format(response.json()))
     self.assertEqual(200, response.status_code)
     self.assertEqual(200, response.json().get("status"))
     #3、 发送第三方的开户请求
     form_data = response.json().get("description").get("form")
     logging.info('form response={}'.format(form_data))
     #调用第三方接口的请求方法
     response = request_third_api(form_data)
     #断言响应结果
     self.assertEqual(200, response.status_code)
     self.assertEqual('UserRegister OK', response.text)
    def test04_recharge_success(self):
        """充值"""
        # 获取充值验证码
        r = random.random()
        response = self.trust_api.get_recharge_verify_code(self.session, str(r))
        self.assertEqual(200, response.status_code)
        logging.info("get_recharge_code response={}".format(response.text))

        # 充值
        amount = '1000'
        response = self.trust_api.recharge(self.session, amount)
        logging.info("recharge response={}".format(response.text))
        # 断言获取的开户信息是否正确
        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 = request_third_api(form_data)
        logging.info("third-interface response={}".format(response.text))
        # 断言第三方接口请求处理是否成功
        self.assertEqual('NetSave OK', response.text)