liumiaomiao 2 سال پیش
والد
کامیت
88a3885577

+ 0 - 0
cases/登录功能/login.py → cases/login.py


BIN
cases/登录功能/搜索功能/__pycache__/bidsearch.cpython-38.pyc


BIN
cases/登录功能/搜索功能/__pycache__/buyersearch.cpython-38.pyc


BIN
cases/登录功能/搜索功能/__pycache__/enterpriseSearch.cpython-38.pyc


BIN
cases/登录功能/搜索功能/__pycache__/supplySearch.cpython-38.pyc


+ 16 - 0
cases/登录功能/搜索功能/bidsearch.py

@@ -0,0 +1,16 @@
+
+from hytest import *
+from lib.webapi import apimgr
+class c2:
+    #测试用例名称
+    name='招标搜索接口'
+    #测试步骤
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1,'第一步调用函数')    #会出现在测试报告中
+        res = apimgr.bidsearch()
+        code = res.status_code
+        INFO(res)
+        STEP(2,'第二步设置检查点')
+        #设置检查点
+        CHECK_POINT('检查搜索接口是否正常',code == 200)

+ 1 - 10
cases/登录功能/搜索功能/buyersearch.py

@@ -7,22 +7,13 @@ from lib.webapi import apimgr
 class c5:
     #测试用例名称
     name='采购单位搜索'
-    # 初始化方法
-    def setup(self):
-        INFO('初始化方法')
     #测试步骤
     def teststeps(self):
         INFO('测试步骤')
         STEP(1,'第一步调用函数')    #会出现在测试报告中
-        apimgr.mgr_login()
         r = apimgr.buyersousuo("万达信息股份有限公司")
         response_data = json.loads(r.text)
         error_code = response_data["error_code"]
         STEP(2, '第二步设置检查点')
         # 设置检查点
-        CHECK_POINT('检查搜索接口是否正常', error_code == 0)
-    #清除方法
-    def teardown(self):
-        INFO('清除方法')
-
-    apimgr.mgr_logout()
+        CHECK_POINT('检查搜索接口是否正常', error_code == 0)

+ 1 - 10
cases/登录功能/搜索功能/enterpriseSearch.py

@@ -5,14 +5,10 @@ from lib.webapi import apimgr
 class c3:
     #测试用例名称
     name='企业搜索'
-    # 初始化方法
-    def setup(self):
-        INFO('初始化方法')
     #测试步骤
     def teststeps(self):
         INFO('测试步骤')
         STEP(1,'第一步调用函数')    #会出现在测试报告中
-        apimgr.mgr_login()
         r = apimgr.enterpriseSearch()
         if r is not None:
             try:
@@ -27,9 +23,4 @@ class c3:
 
         STEP(2,'第二步设置检查点')
         #设置检查点
-        CHECK_POINT('检查登录接口是否正常',textactual_legal_person == "田小亮")
-    #清除方法
-    def teardown(self):
-        INFO('清除方法')
-
-    apimgr.mgr_logout()
+        CHECK_POINT('检查登录接口是否正常',textactual_legal_person == "田小亮")

+ 0 - 25
cases/登录功能/搜索功能/purchasesearch.py

@@ -1,25 +0,0 @@
-
-from hytest import *
-from lib.webapi import apimgr
-class c2:
-    #测试用例名称
-    name='招标搜索接口'
-    # 初始化方法
-    def setup(self):
-        INFO('初始化方法')
-        self.session = apimgr.mgr_login()
-    #测试步骤
-    def teststeps(self):
-        INFO('测试步骤')
-        STEP(1,'第一步调用函数')    #会出现在测试报告中
-        apimgr.mgr_login()
-        r = apimgr.purchasesearch()
-        res = r.text
-        keys_value = res.split('var keys = "', 1)[-1].split('"', 1)[0]
-        STEP(2,'第二步设置检查点')
-        #设置检查点
-        CHECK_POINT('检查搜索接口是否正常',keys_value == "建筑")
-    #清除方法
-    def teardown(self):
-        INFO('清除方法')
-        apimgr.mgr_logout()

+ 0 - 9
cases/登录功能/搜索功能/supplySearch.py

@@ -7,22 +7,13 @@ from lib.webapi import apimgr
 class c4:
     #测试用例名称
     name='供应搜索'
-    # 初始化方法
-    def setup(self):
-        INFO('初始化方法')
     #测试步骤
     def teststeps(self):
         INFO('测试步骤')
         STEP(1,'第一步调用函数')    #会出现在测试报告中
-        apimgr.mgr_login()
         r = apimgr.supplySearch()
         # INFO(r.json())
         res = json.loads(r.content.decode('utf-8'))
         STEP(2,'第二步设置检查点')
         #设置检查点
         CHECK_POINT('检查搜索接口是否正常',res['data']['ckeys'] == 'PH计')
-    #清除方法
-    def teardown(self):
-        INFO('清除方法')
-
-    apimgr.mgr_logout()

+ 5 - 8
lib/webapi.py

@@ -66,17 +66,14 @@ class APIMgr():
         s.post(url=url, headers=headers)
         # self.printResponse(res)
         # return res
-
-    def purchasesearch(self, keywords="建筑", publishtime="fiveyear", selectType="content"):
+    #招标搜索
+    def bidsearch(self, keywords="建筑", publishtime="fiveyear", selectType="content"):
         #使用全局变量
         headers = GSTORE['headers']
+        params={"keywords":keywords,"publishtime":publishtime,"timeslot":"","area":"","subtype":"","minprice":"","maxprice":"","industry":"","buyerclass":"","buyertel":"","winnertel":"","selectType":selectType,"notkey":"","fileExists":"0","city":"","searchGroup":"0","searchMode":"0","wordsMode":"0","additionalWords":""}
         #保存session
         session = self.s
-        response = session.post(f"{cfg.target_host}/jylab/supsearch/index.html", headers=headers, data={
-            'keywords': keywords,
-            'publishtime': publishtime,
-            'selectType': selectType
-        })
+        response = session.post(f"{cfg.target_host}/jylab/supsearch/index.html", headers=headers, params=params)
         self.printResponse(response)
         return response
 
@@ -134,7 +131,7 @@ class APIMgr():
         response = requests.post(url=url, json=data, headers=self.headers)
         self.printResponse(response)
         return response
-
+    #接口数据传值常用三种方式:urlencoded---params,键值对---data,json格式---json
     #获取推送记录接口
     def push_list(self):
         headers=GSTORE['headers']