فهرست منبع

app登录接口验证

liumiaomiao 2 سال پیش
والد
کامیت
6f965d10da
4فایلهای تغییر یافته به همراه53 افزوده شده و 5 حذف شده
  1. 2 2
      cases/login.py
  2. 20 0
      cases/login_app.py
  3. 2 1
      cfg/cfg.py
  4. 29 2
      lib/webapi.py

+ 2 - 2
cases/login.py

@@ -2,7 +2,7 @@ from hytest import *
 from lib.webapi import apimgr
 class c1:
     #测试用例名称
-    name='登录接口验证'
+    name='pc登录接口验证'
     #测试步骤
     def teststeps(self):
         INFO('测试步骤')
@@ -13,7 +13,7 @@ class c1:
         actural = res['userInfo']['result']
         STEP(2,'第二步设置检查点')
         #设置检查点
-        CHECK_POINT('检查登录接口是否正常',actural =="ok")
+        CHECK_POINT('检查pc登录接口是否正常',actural =="ok")
     #清除方法
     def teardown(self):
         INFO('用户退出')

+ 20 - 0
cases/login_app.py

@@ -0,0 +1,20 @@
+from hytest import *
+from lib.webapi import apimgr
+class c1:
+    #测试用例名称
+    name='app登录接口验证'
+    #测试步骤
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1,'打印接口返回值')    #会出现在测试报告中
+        r = apimgr.mgr_login_app()
+        res = r.json()
+        INFO(res)
+        actural = res['status']
+        STEP(2,'第二步设置检查点')
+        #设置检查点
+        CHECK_POINT('检查app登录接口是否正常',actural == 1)
+    #清除方法
+    def teardown(self):
+        INFO('用户退出app')
+        apimgr.mgr_login_app()

+ 2 - 1
cfg/cfg.py

@@ -1 +1,2 @@
-target_host = 'https://www.jianyu360.cn'
+target_host = 'https://www.jianyu360.cn'
+target_host_app = 'https://app-a1.jianyu360.cn'

+ 29 - 2
lib/webapi.py

@@ -42,7 +42,7 @@ class APIMgr():
     # session对象设置为全局变量
     s = requests.Session()
     GSTORE['s'] = s
-    #登录接口
+    #pc登录接口
     def mgr_login(self, phone='18211989987', password='123456',useproxies=False):
         headers=GSTORE['headers']
         s = GSTORE['s']
@@ -59,7 +59,27 @@ class APIMgr():
         # 把response对象返回出去
         return response
 
-    """退出登录"""
+    # app登录接口
+    def mgr_login_app(self, phone='18211989987', password='123456',useproxies=False):
+        headers=GSTORE['headers']
+        s = GSTORE['s']
+        if useproxies:
+            self.s.proxies.update({'http':'127.0.0.1:8888'})
+        response = self.s.post(f"{cfg.target_host_app}/jyapp/free/login",headers=headers,params=
+                                    {
+                                     'reqType': 'phoneLogin',
+                                     'phone':phone,
+                                     'password':password,
+                                     'rid':'',
+                                     'oid': '',
+                                     'phoneType': '',
+                                     'channel': '',
+                                     'deviceId': ''
+                                    })
+        self.printResponse(response)
+        # 把response对象返回出去
+        return response
+    """退出登录pc"""
     def mgr_logout(self):
         url = f"{cfg.target_host}/front/signOut"
         headers = GSTORE['headers']
@@ -67,6 +87,13 @@ class APIMgr():
         s.post(url=url, headers=headers)
         # self.printResponse(res)
         # return res
+
+    """退出登录app"""
+    def mgr_logout_app(self):
+        url = f"{cfg.target_host_app}/jyapp/free/signOut"
+        headers = GSTORE['headers']
+        s = GSTORE['s']
+        s.post(url=url, headers=headers)
     #招标搜索
     def bidsearch(self, keywords="建筑", publishtime="fiveyear", selectType="content"):
         #使用全局变量