python3+requests接口自动化-其他接口封装

基于登陆session会话的其他接口封装

 1 from case.login import test_user_login
 2 import unittest
 3 import requests
 4 from common.logger import Log
 5 from config import cof
 6 
 7 s = requests.Session()
 8 class user_transfer(unittest.TestCase):
 9     log = Log()
10     def setUp(self):
11         self.s = test_user_login().test_Login()
12     def test_Transfer(self):
13         data = {"Amount": 5,
14                     "GamePlatform": "xxxx"
15                     }
16         route = "/api/Transfer/DoTransferToGame"
17         url = "".join([cof.route(), route])
18         r = s.post(url,data=data)
19         try:
20             self.log.info("调用登陆结果:%s" %r)
21             self.log.info("获取是否登陆成功:%s"%r.text)
22             self.assertEqual(r.status_code, 200)  # 拿结果断言
23             self.log.info("---------test is pass---------")
24             self.log.info("---------end---------")
25         except:
26             self.log.info("---------test is fail---------")
27 
28 if __name__ == "__main__":
29     unittest.main()

 

posted @ 2018-10-23 13:24  jaysonzxk  阅读(333)  评论(0编辑  收藏  举报