#!/user/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/7/7 15:41 # @Author :Test_zhangping # @Email :981874735@qq.com # @File :api_recharge.py """ 充值接口: 所有的用例前置:登录 拿到2个数据 :id token 把前置的数据 传递到测试用例 充值接口的请求数据:id 请求头:token """ import unittest from jsonpath import jsonpath from Class_Request_API_接口自动化.class_day6.Common.handle_phone import get_old_phone from Class_Request_API_接口自动化.class_day6.Common.handle_requests import send_requests class TestRecharge(unittest.TestCase): @classmethod def setUpClass(cls) -> None: # 得到登陆的用户名和密码 user,passwd = get_old_phone() # 登陆接口调用。 resp = send_requests("POST","member/login",{"mobile_phone":user,"pwd":passwd}) # 得到的id,token设置为类属性 # print("登陆的响应结果为:") # print(resp.text) cls.user_id = jsonpath(resp.json(),"$..id")[0] cls.token = jsonpath(resp.json(),"$..token")[0] # cls.id = "10000" # cls.token = "111111" def test_recharge(self): print(self.user_id) print(self.token) pass