Bläddra i källkod

小程序接口

lizhikun 7 månader sedan
förälder
incheckning
61c1f72021

+ 16 - 0
cases/fragmentation/未登录/小程序信息获取/debrisproduct_buyer_getList.py

@@ -0,0 +1,16 @@
+from hytest import *
+from lib.webapi import apimgr
+
+class c1:
+    name = '业主单位列表'
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1, '第一步调用函数')
+        res=apimgr.debrisproduct_getAssName()
+        r = res.json()
+        INFO(r)
+
+        actural1=r['error_code']
+        STEP(2, '第二步设置检查点')
+        # 设置检查点
+        CHECK_POINT('检查业主单位列表接口是否正常',actural1 == 0)

+ 16 - 0
cases/fragmentation/未登录/小程序信息获取/debrisproduct_buyer_getSearchList.py

@@ -0,0 +1,16 @@
+from hytest import *
+from lib.webapi import apimgr
+
+class c1:
+    name = '业主搜索历史'
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1, '第一步调用函数')
+        res=apimgr.debrisproduct_buyer_getSearchList()
+        r = res.json()
+        INFO(r)
+
+        actural1=r['error_code']
+        STEP(2, '第二步设置检查点')
+        # 设置检查点
+        CHECK_POINT('检查业主搜索历史接口是否正常',actural1 == 0)

+ 16 - 0
cases/fragmentation/未登录/小程序信息获取/debrisproduct_getAdList.py

@@ -0,0 +1,16 @@
+from hytest import *
+from lib.webapi import apimgr
+
+class c1:
+    name = '获取小程序广告位'
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1, '第一步调用函数')
+        res=apimgr.debrisproduct_getAdList()
+        r = res.json()
+        INFO(r)
+
+        actural1=r['error_code']
+        STEP(2, '第二步设置检查点')
+        # 设置检查点
+        CHECK_POINT('检查广告位是否正常',actural1 == 0)

+ 16 - 0
cases/fragmentation/未登录/小程序信息获取/debrisproduct_getAllBusiness.py

@@ -0,0 +1,16 @@
+from hytest import *
+from lib.webapi import apimgr
+
+class c1:
+    name = '所有商机获取'
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1, '第一步调用函数')
+        res=apimgr.debrisproduct_getAllBusiness()
+        r = res.json()
+        INFO(r)
+
+        actural1=r['error_code']
+        STEP(2, '第二步设置检查点')
+        # 设置检查点
+        CHECK_POINT('检查获取商机接口是否正常',actural1 == 0)

+ 16 - 0
cases/fragmentation/未登录/小程序信息获取/debrisproduct_getAssName.py

@@ -0,0 +1,16 @@
+from hytest import *
+from lib.webapi import apimgr
+
+class c1:
+    name = '业主单位名称联想'
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1, '第一步调用函数')
+        res=apimgr.debrisproduct_getAssName()
+        r = res.json()
+        INFO(r)
+
+        actural1=r['error_code']
+        STEP(2, '第二步设置检查点')
+        # 设置检查点
+        CHECK_POINT('检查业主单位名称联想接口是否正常',actural1 == 0)

+ 16 - 0
cases/fragmentation/未登录/小程序信息获取/debrisproduct_getPriceList.py

@@ -0,0 +1,16 @@
+from hytest import *
+from lib.webapi import apimgr
+
+class c1:
+    name = '获取产品价格'
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1, '第一步调用函数')
+        res=apimgr.debrisproduct_getPriceList()
+        r = res.json()
+        INFO(r)
+
+        actural1=r['error_code']
+        STEP(2, '第二步设置检查点')
+        # 设置检查点
+        CHECK_POINT('检查获取产品价格接口是否正常',actural1 == 0)

+ 16 - 0
cases/fragmentation/未登录/小程序信息获取/debrisproduct_getconfig.py

@@ -0,0 +1,16 @@
+from hytest import *
+from lib.webapi import apimgr
+
+class c1:
+    name = '获取小程序配置'
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1, '第一步调用函数')
+        res=apimgr.debrisproduct_getLocation()
+        r = res.json()
+        INFO(r)
+
+        actural1=r['error_code']
+        STEP(2, '第二步设置检查点')
+        # 设置检查点
+        CHECK_POINT('检查获取小程序配置接口是否正常',actural1 == 0)

+ 16 - 0
cases/fragmentation/未登录/小程序信息获取/debrisproduct_location.py

@@ -0,0 +1,16 @@
+from hytest import *
+from lib.webapi import apimgr
+
+class c1:
+    name = '获取地理位置'
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1, '第一步调用函数')
+        res=apimgr.debrisproduct_getLocation()
+        r = res.json()
+        INFO(r)
+
+        actural1=r['error_code']
+        STEP(2, '第二步设置检查点')
+        # 设置检查点
+        CHECK_POINT('检查获取位置接口是否正常',actural1 == 0)

+ 28 - 0
cases/fragmentation/登录/我的/debrisproduct_orderDetail.py

@@ -0,0 +1,28 @@
+from hytest import *
+from lib.wxapi import apimgr
+
+class c1:
+    name = '获取订单详情'
+
+    def teststeps(self):
+        INFO('测试步骤')
+
+        # STEP 1: 调用获取订单详情接口
+        STEP(1, '调用获取订单详情接口')
+        try:
+            # 确保传递正确的 orderCode 参数
+            orderCode = '262059625763'  # 你可以替换为实际的订单号
+            res = apimgr.debrisproduct_orderDetail(orderCode=orderCode)  # 调用接口并传递参数
+            r = res.json()  # 解析返回的 JSON
+            INFO(f"返回数据: {r}")  # 打印返回数据,帮助调试
+
+        except Exception as e:
+            INFO(f'获取订单详情失败: {e}')  # 打印异常信息
+            raise
+
+        # STEP 2: 设置检查点
+        STEP(2, '设置检查点')
+        # 获取 error_code,默认值为 -1,防止没有该字段时报错
+        actual_error_code = r.get('error_code', -1)
+        CHECK_POINT('检查获取订单详情接口是否正常', actual_error_code == 0)
+

+ 28 - 0
cases/fragmentation/登录/我的/debrisproduct_orderList.py

@@ -0,0 +1,28 @@
+from hytest import *
+from lib.wxapi import apimgr
+
+class c1:
+    name = '获取订单列表'
+
+    def teststeps(self):
+        INFO('测试步骤')
+
+        # STEP 1: 调用获取订单详情接口
+        STEP(1, '调用获取订单列表接口')
+        try:
+            # 确保传递正确的 orderCode 参数
+            orderCode = '262059625763'  # 你可以替换为实际的订单号
+            res = apimgr.debrisproduct_orderDetail(orderCode=orderCode)  # 调用接口并传递参数
+            r = res.json()  # 解析返回的 JSON
+            INFO(f"返回数据: {r}")  # 打印返回数据,帮助调试
+
+        except Exception as e:
+            INFO(f'获取订单详情失败: {e}')  # 打印异常信息
+            raise
+
+        # STEP 2: 设置检查点
+        STEP(2, '设置检查点')
+        # 获取 error_code,默认值为 -1,防止没有该字段时报错
+        actual_error_code = r.get('error_code', -1)
+        CHECK_POINT('检查获取订单列表接口是否正常', actual_error_code == 0)
+

+ 33 - 90
doc/zbsousuo.py

@@ -1,90 +1,33 @@
-import json
-
-import requests
-
-headers1 = {
-    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
-}
-
-url = "https://www.jianyu360.cn/phone/login"
-data={
-"reqType": "phoneLogin",
-"isAutoLogin": "false",
-"phone": "18211989987",
-"password": "123456"
-}
-res = requests.post(url=url,headers=headers1,data=data)
-print(res)
-assert res.status_code==200
-assert res.json()["status"] == 1
-assert res.json()["userInfo"]["result"] == "ok"
-assert res.json()["userInfo"]["s_nickname"] == "182****9987"
-cookies=res.cookies
-# print(cookies)
-# print(res.status_code)
-print(res.json())
-cookie_dict = cookies.get_dict()
-session_id = cookie_dict.get("SESSIONID")
-headers = {
-"Content-Type": "application/json",
-"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67",
-    "Cookie": f"SESSIONID={session_id}"
-}
-# print(headers)
-# url = "https://www.jianyu360.cn/jylab/supsearch/index.html"
-# data={
-# "keywords": "建筑",
-# "publishtime": "fiveyear",
-# "selectType": "content"
-# }
-
-# response = requests.post(url=url, headers=headers,data=data)
-# text=response.text
-# print(text)
-# response_text = response.text  # 假设 response 是请求的响应对象,将响应体保存在 response_text 变量中
-
-# 提取 keys 的值
-# keys_value = response_text.split('var keys = "', 1)[-1].split('"', 1)[0]
-
-# 断言 keys 等于 "建筑"
-# assert keys_value == "建筑"
-# url3="https://www.jianyu360.cn/succbi/api/dw/services/queryData"
-# data={"query":
-#           {"resid":"rk6LnRZndKIcnSYLtlpwVG","fields":[{"name":"XMLBDMHZ"}],"sources":"null","filter":[],"params":
-#               [{"name":"searchinput3","value":"科技"}],"sort":[],"options":
-#               {"limit":1,"offset":0,"needResultFilter":"true","queryTotalRowCount":"false"},"queryId":"model6"},
-#                 "resid":"rk6LnRZndKIcnSYLtlpwVG"}
-# rseb=requests.post(url=url,data=data,headers=headers)
-# print(rseb.text)
-# url="https://www.jianyu360.cn/publicapply/enterpriseSearch/doQuery"
-# data={
-# "match": "北京剑鱼信息技术有限公司河南分公司",
-# "matchType": "A",
-# "pageSize": "10",
-# "pageNum": "0"
-# }
-# qq=requests.post(url=url,data=data,headers=headers)
-# print(qq.text)
-
-url2 = "https://www.jianyu360.cn/jyapi/jybx/buyer/eType/buyerList"
-data = {
-    "buyerName": "万达信息股份有限公司",
-    "province": [],
-    "city": [],
-    "buyerClass": [],
-    "isCheckFollow": True,
-    "isCheckReceive": True,
-    "isContact": 0,
-    "pageSize": 10,
-    "pageNum": 1
-}
-
-response = requests.post(url=url2, data=json.dumps(data), headers=headers)
-
-
-print(response.text)
-url3="https://www.jianyu360.cn/jyinfo/supplySearch"
-data={"keywords":"PH计","searchType":"title","province":"","city":"","time":"","status":"0","pageSize":50,"pageIndex":1}
-resa=requests.post(url=url3,headers=headers,data=json.dumps(data))
-res = json.loads(resa.content.decode('utf-8'))
-assert res['data']['ckeys'] == 'PH计'
+from hytest import *
+from lib.webapi import apimgr
+
+
+class c1:
+    name = '我的'
+
+    def teststeps(self):
+        INFO('测试步骤')
+
+        # STEP 1: 调用小程序登录接口,获取 cookies
+        STEP(1, '调用小程序登录接口获取 cookies')
+        try:
+            apimgr.mgr_get_cookie(phone='15037870765', token='8817684142977367381')
+            INFO('Cookies 获取成功')
+        except Exception as e:
+            INFO(f'获取 Cookies 失败: {e}')
+            raise
+
+        # STEP 2: 调用获取订单详情接口
+        STEP(2, '调用获取订单详情接口')
+        try:
+            res = apimgr.debrisproduct_orderDetail(order_id='12345')
+            r = res.json()
+            INFO(r)
+        except Exception as e:
+            INFO(f'调用订单详情接口失败: {e}')
+            raise
+
+        # STEP 3: 设置检查点
+        STEP(3, '设置检查点')
+        actual_error_code = r.get('error_code')
+        CHECK_POINT('检查获取订单详情接口是否正常', actual_error_code == 0)

+ 47 - 1
lib/webapi.py

@@ -42,9 +42,15 @@ class APIMgr():
     headers = {
         "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67;jy-test"
     }
-
+    # 定义第二个 headers
+    headers_1 = {
+        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67;jy-test",
+        "Content-Type":"application/json",
+        "MiniprogramCode":"wy_zbxm"
+    }
     #headers设置为全局变量
     GSTORE['headers'] = headers
+    GSTORE['headers_1'] = headers_1
     # session对象设置为全局变量
     s = requests.Session()
     GSTORE['s'] = s
@@ -1029,6 +1035,46 @@ class APIMgr():
         header = GSTORE['headers']
         response = self.s.post(f"{cfg.target_host}/bigmember/search/buyer/association?name=河南科技大学", headers=header)
         return response
+    #获取小程序广告位
+    def debrisproduct_getAdList(self):
+        headers_1 = GSTORE['headers_1']
+        response = self.s.post(f"{cfg.target_host_wxapi}/debrisproduct/free/getAdList", headers=headers_1,data={"Code":"jy-appsearch-home-top"})
+        return response
+    #获取地理位置
+    def debrisproduct_getLocation(self):
+        headers_1 = GSTORE['headers_1']
+        response = self.s.get(f"{cfg.target_host_wxapi}/debrisproduct/free/location", headers=headers_1)
+        return response
+    #所有商机获取
+    def debrisproduct_getAllBusiness(self):
+        headers_1 = GSTORE['headers_1']
+        response = self.s.post(f"{cfg.target_host_wxapi}/debrisproduct/free/getAllBusiness", headers=headers_1)
+        return response
+    #获取小程序配置
+    def debrisproduct_getConfig(self):
+        headers_1 = GSTORE['headers_1']
+        response = self.s.post(f"{cfg.target_host_wxapi}/debrisproduct/free/getSetting", headers=headers_1)
+        return response
+    #业主单位名称联想
+    def debrisproduct_getAssName(self):
+        headers_1 = GSTORE['headers_1']
+        response = self.s.post(f"{cfg.target_host_wxapi}/debrisproduct/buyer/getAssName", headers=headers_1,data={"buyerName":"科技"})
+        return response
+    #业主单位列表
+    def debrisproduct_getList(self):
+        headers_1 = GSTORE['headers_1']
+        response = self.s.post(f"{cfg.target_host_wxapi}/debrisproduct/buyer/getList", headers=headers_1,data={"page_num":10,"pagesize":1})
+        return response
+    #业主搜索历史
+    def debrisproduct_buyer_getSearchList(self):
+        headers_1 = GSTORE['headers_1']
+        response = self.s.post(f"{cfg.target_host_wxapi}/debrisproduct/buyer/getSearchList", headers=headers_1)
+        return response
+    #获取价格列表
+    def debrisproduct_getPriceList(self):
+        headers_1 = GSTORE['headers_1']
+        response = self.s.post(f"{cfg.target_host_wxapi}/debrisproduct/getPriceList", headers=headers_1)
+        return response
 
 apimgr = APIMgr()
 

+ 21 - 2
lib/wxapi.py

@@ -205,7 +205,26 @@ class APIMgr():
         }
         response = s.post(f"{cfg.target_host_wxapi}/debrisproduct/getBiddingDetail", headers=hearders, json=json)
         return response
-
-
+    #获取订单详情
+    def debrisproduct_orderDetail(self, orderCode):
+        headers = GSTORE['headers']
+        s = GSTORE['s']  # 从全局变量中获取 cookie
+        INFO(f"使用的 cookies: {s}")  # 打印 cookie,确保它正确
+        response = s.post(
+            f"{cfg.target_host_wxapi}/debrisproduct/orderDetail",
+            headers=headers,
+            data={"orderCode": orderCode}
+        )
+        return response
+    #获取订单列表
+    def debrisproduct_orderList(self, orderCode):
+        headers = GSTORE['headers']
+        s = GSTORE['s']  # 从全局变量中获取 cookie
+        INFO(f"使用的 cookies: {s}")  # 打印 cookie,确保它正确
+        response = s.post(
+            f"{cfg.target_host_wxapi}/debrisproduct/orderList",
+            headers=headers,
+            data={"orderCode": orderCode}
+        )
 
 apimgr = APIMgr()