Commit 8b4a8e7d authored by liguangyu06's avatar liguangyu06
Browse files

优化用例

parent 4e41496c
......@@ -8,6 +8,7 @@ case_tag:cmdc_api,cmdc用户购物车商品移除,2252,2252-4,sit,bs
from common.common_func import commonFuc
from air_case.cmdc_login.多彩商城登录.多彩商城登录 import CmdcMaiiLogin
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
......@@ -20,16 +21,33 @@ password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers3", cmdc_access_token)
# 获取登录后台管理系统所需账号密码
username1 = commonFuc().get_business_data(module, "username1")
password1 = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username1, password1).get_token()
headers1 = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url20")
request_body = commonFuc().get_business_data(module, "payload20")
# 发送请求
result = requests.post(url, json=request_body, headers=headers1)
result = json.loads(result.content)
product_id = result["data"]["list"][0]["productId"]
price = result["data"]["list"][0]["referencePrice"]
# 第二步在购物车中新增商品
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body1 = commonFuc().get_business_data(module, "payload2")
request_body1 = commonFuc().get_business_data(module, "payload2", product_id, price)
result1 = requests.post(url1, json=request_body1, headers=headers)
result1 = json.loads(result1.content)
# 第三步查询购物车中新增的商品信息
url2 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body2 = commonFuc().get_business_data(module, "payload1")
result2 = requests.post(url2, json=request_body2, headers=headers)
result2 = json.loads(result2.content)
print(result2)
# 获取所添加商品id
product_id = commonFuc().get_business_data(module, "payload2")["productId"]
result_product_id = result2["data"]["list"][0]["list"][0]["productId"]
......
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