Commit 31c4d0ae authored by liguangyu06's avatar liguangyu06
Browse files

用例优化

1 merge request!1代码归档只main分支
Showing with 13 additions and 7 deletions
+13 -7
...@@ -12,7 +12,6 @@ from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 impor ...@@ -12,7 +12,6 @@ from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 impor
import requests import requests
import json import json
module = "cmdc_buyercar_list" module = "cmdc_buyercar_list"
# 步骤一登录后台管理系统查询已失效商品列表获取已下架商品信息 # 步骤一登录后台管理系统查询已失效商品列表获取已下架商品信息
...@@ -22,14 +21,17 @@ password = commonFuc().get_business_data(module, "password2") ...@@ -22,14 +21,17 @@ password = commonFuc().get_business_data(module, "password2")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 获取已失效商品
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url50") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url50")
request_body = commonFuc().get_business_data(module, "payload50") request_body = commonFuc().get_business_data(module, "payload50")
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content) result = json.loads(result.content)
# 获取商品信息
product_id = result["data"]["list"][0]["productId"] product_id = result["data"]["list"][0]["productId"]
price = result["data"]["list"][0]["referencePrice"] price = result["data"]["list"][0]["referencePrice"]
filiale_code = result["data"]["list"][0]["filialeCode"] filiale_code = result["data"]["list"][0]["filialeCode"]
# 第二步登录多采商城添加商品至购物车列表 # 第二步登录多采商城添加商品至购物车列表
# 获取登录多采商城所需账号密码 # 获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username")
...@@ -37,8 +39,10 @@ password = commonFuc().get_business_data(module, "password") ...@@ -37,8 +39,10 @@ password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token() cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers5", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers5", cmdc_access_token)
# 添加商品至购物车
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body = commonFuc().get_business_data(module, "payload5", product_id, price, filiale_code) request_body = commonFuc().get_business_data(module, "payload5", product_id, price, filiale_code)
""" """
场景:新增已失效的商品至购物车列表 场景:新增已失效的商品至购物车列表
用例名称:新增已失效的商品至购物车列表 用例名称:新增已失效的商品至购物车列表
......
...@@ -50,7 +50,6 @@ excel.write_data(row=2, column=4, value=customer_name) ...@@ -50,7 +50,6 @@ excel.write_data(row=2, column=4, value=customer_name)
# 第二步文件导入 # 第二步文件导入
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url18") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url18")
request_body = commonFuc().get_business_data(module, "payload18") request_body = commonFuc().get_business_data(module, "payload18")
# 获取文件 # 获取文件
...@@ -67,7 +66,7 @@ fresenius_price_id = result["data"]["freseniusAgreementPrices"][0]["freseniusPri ...@@ -67,7 +66,7 @@ fresenius_price_id = result["data"]["freseniusAgreementPrices"][0]["freseniusPri
# 第三步进行特价单品删除操作 # 第三步进行特价单品删除操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_open") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_open")
request_body = {"freseniusPriceIds": [fresenius_price_id], "groupPriceStatus": 1, "remarks": "特价单品启用"} request_body = {"freseniusPriceIds": [fresenius_price_id], "groupPriceStatus": 1, "remarks": "特价单品启用"}
print(request_body)
""" """
场景:启用_批量_特价单品 场景:启用_批量_特价单品
用例名称:启用_批量_特价单品 用例名称:启用_批量_特价单品
...@@ -86,7 +85,8 @@ if result["success"]: ...@@ -86,7 +85,8 @@ if result["success"]:
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db") host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询特价单品数量 # 数据库查询特价单品数量
sql = "SELECT t.groupPriceStatus FROM `cmdc-order`.tc_fresenius_agreement_price t WHERE groupId = {};".format(group_id) sql = "SELECT t.groupPriceStatus FROM `cmdc-order`.tc_fresenius_agreement_price t WHERE groupId = {};".format(
group_id)
print(sql) print(sql)
result = {"groupPriceStatus": mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]} result = {"groupPriceStatus": mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]}
print(result) print(result)
...@@ -99,4 +99,4 @@ else: ...@@ -99,4 +99,4 @@ else:
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict180") check_dict = commonFuc().get_business_data(module, "checkDict180")
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
\ No newline at end of file
...@@ -24,7 +24,7 @@ headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_toke ...@@ -24,7 +24,7 @@ headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_toke
# 第二步套包协议特价查询 # 第二步套包协议特价查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3")
request_body = commonFuc().get_business_data(module, "payload3") request_body = commonFuc().get_business_data(module, "payload03")
""" """
场景:验证套包协议特价接口返回数据与数据库数据是否一致 场景:验证套包协议特价接口返回数据与数据库数据是否一致
用例名称:套包协议价查询 用例名称:套包协议价查询
...@@ -48,7 +48,9 @@ sql = "SELECT t.* FROM `cmdc-order`.tc_fresenius_agreement_price t " \ ...@@ -48,7 +48,9 @@ sql = "SELECT t.* FROM `cmdc-order`.tc_fresenius_agreement_price t " \
"WHERE companyCode = 00111 and isRegularPrice = 0 and " \ "WHERE companyCode = 00111 and isRegularPrice = 0 and " \
"groupId in (SELECT t.groupId FROM `cmdc-order`.tc_fresenius_group t " \ "groupId in (SELECT t.groupId FROM `cmdc-order`.tc_fresenius_group t " \
"WHERE status = 1 and groupType = 0);" "WHERE status = 1 and groupType = 0);"
print(sql)
total = len(mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)) total = len(mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql))
print(total)
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3", total) check_dict = commonFuc().get_business_data(module, "checkDict3", total)
......
...@@ -40,6 +40,7 @@ checkDict2: {"total":"%s"} ...@@ -40,6 +40,7 @@ checkDict2: {"total":"%s"}
#测试场景三:套包协议特价查询 #测试场景三:套包协议特价查询
"url3": "/order/public/queryFreseniusAgreementPricePageInfo" "url3": "/order/public/queryFreseniusAgreementPricePageInfo"
"payload3": {"groupCode":"","groupName":"","productCode":"","productInfo":"","materialCode":"","manufacturerList":[],"productLineName":"","description":"","manufacturerProductDesc":"","manufacturerProductNo":"","customerCode":"","customerName":"","manufacturerUserNo":"","manufacturerUserDesc":"","documentNo":"","companyCode":"","groupType":0,"status":null,"pageStart":null,"pageSize":null} "payload3": {"groupCode":"","groupName":"","productCode":"","productInfo":"","materialCode":"","manufacturerList":[],"productLineName":"","description":"","manufacturerProductDesc":"","manufacturerProductNo":"","customerCode":"","customerName":"","manufacturerUserNo":"","manufacturerUserDesc":"","documentNo":"","companyCode":"","groupType":0,"status":null,"pageStart":null,"pageSize":null}
"payload03": {"groupCode":"","groupName":"","productCode":"","productInfo":"","materialCode":"","manufacturerList":[],"productLineName":"","description":"","manufacturerProductDesc":"","manufacturerProductNo":"","customerCode":"","customerName":"","manufacturerUserNo":"","manufacturerUserDesc":"","documentNo":"","companyCode":"","groupType":0,"status":"1","pageStart":1,"pageSize":10}
#预期结果 #预期结果
checkDict3: {"total":"%s"} checkDict3: {"total":"%s"}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment