Commit a78234b9 authored by liguangyu06's avatar liguangyu06
Browse files

用例优化

parent d067bf09
...@@ -22,8 +22,8 @@ cmdc_access_token = CmdcMaiiLogin(username, password).get_token() ...@@ -22,8 +22,8 @@ cmdc_access_token = CmdcMaiiLogin(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)
# 第二步查询站点对应的companyId # 第二步查询站点对应的companyId
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body1 = commonFuc().get_business_data(module, "payload1") request_body = commonFuc().get_business_data(module, "payload1")
""" """
...@@ -33,11 +33,12 @@ request_body1 = commonFuc().get_business_data(module, "payload1") ...@@ -33,11 +33,12 @@ request_body1 = commonFuc().get_business_data(module, "payload1")
输出:"quickOrderSign": 0 输出:"quickOrderSign": 0
""" """
# 发送请求 # 发送请求
result1 = requests.post(url1, json=request_body1, headers=headers) result = requests.post(url, json=request_body, headers=headers)
result1 = json.loads(result1.text) result = json.loads(result.text)
# 获取站点对应的快速下单标识字段quickOrderSign # 获取站点对应的快速下单标识字段quickOrderSign
result1 = result1["data"] result1 = result["data"]
# 获取订单quickOrderSign进行判断处理
for i in result1: for i in result1:
quick_order_sign = i["quickOrderSign"] quick_order_sign = i["quickOrderSign"]
# 第三步验证站点是否具有快速下单权限 # 第三步验证站点是否具有快速下单权限
......
...@@ -24,6 +24,7 @@ headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_toke ...@@ -24,6 +24,7 @@ headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_toke
# 第二步查询站点对应的companyId # 第二步查询站点对应的companyId
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body1 = commonFuc().get_business_data(module, "payload1") request_body1 = commonFuc().get_business_data(module, "payload1")
# 发送请求
result1 = requests.post(url1, json=request_body1, headers=headers) result1 = requests.post(url1, json=request_body1, headers=headers)
result1 = json.loads(result1.text) result1 = json.loads(result1.text)
# print(result1) # print(result1)
...@@ -44,6 +45,7 @@ if quick_order_sign == 1: ...@@ -44,6 +45,7 @@ if quick_order_sign == 1:
# 获取companyId # 获取companyId
company_id = result1["data"][1]["companyId"] company_id = result1["data"][1]["companyId"]
request_body = commonFuc().get_business_data(module, "payload", company_id) request_body = commonFuc().get_business_data(module, "payload", company_id)
# 发送请求
result = requests.get(url, params=request_body) result = requests.get(url, params=request_body)
result = json.loads(result.text) result = json.loads(result.text)
# 获取预期结果 # 获取预期结果
...@@ -54,6 +56,7 @@ else: ...@@ -54,6 +56,7 @@ else:
# 获取companyId # 获取companyId
company_id = result1["data"][1]["companyId"] company_id = result1["data"][1]["companyId"]
request_body = commonFuc().get_business_data(module, "payload", company_id) request_body = commonFuc().get_business_data(module, "payload", company_id)
# 发送请求
result = requests.get(url, params=request_body) result = requests.get(url, params=request_body)
result = json.loads(result.text) result = json.loads(result.text)
# 获取预期结果 # 获取预期结果
......
...@@ -15,19 +15,24 @@ import json ...@@ -15,19 +15,24 @@ import json
module = "cmdc_buyercar_list" module = "cmdc_buyercar_list"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password") 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_headers4", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers4", cmdc_access_token)
# 添加商品至购物车列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body = commonFuc().get_business_data(module, "payload4") request_body = commonFuc().get_business_data(module, "payload4")
""" """
场景:新增不存在的商品至购物车列表 场景:新增不存在的商品至购物车列表
用例名称:新增不存在的商品至购物车列表 用例名称:新增不存在的商品至购物车列表
输出:{"success":false,"code":"1078","message":"该商品不存在,加入购物车失败","data":null,"freshToken":null} 输出:{"success":false,"code":"1078","message":"该商品不存在,加入购物车失败","data":null,"freshToken":null}
""" """
# 发送请求 # 发送请求
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)
......
...@@ -21,33 +21,38 @@ password = commonFuc().get_business_data(module, "password2") ...@@ -21,33 +21,38 @@ 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")
password = commonFuc().get_business_data(module, "password") 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)
""" """
场景:新增已失效的商品至购物车列表 场景:新增已失效的商品至购物车列表
用例名称:新增已失效的商品至购物车列表 用例名称:新增已失效的商品至购物车列表
输出:{"success":false,"code":"addBuyerCartFail","message":"商品为失效状态,不可加入购物车","data":null,"freshToken":null} 输出:{"success":false,"code":"addBuyerCartFail","message":"商品为失效状态,不可加入购物车","data":null,"freshToken":null}
""" """
# 发送请求 # 发送请求
result = requests.post(url1, json=request_body, headers=headers) result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content) result = json.loads(result.content)
......
...@@ -21,30 +21,38 @@ password = commonFuc().get_business_data(module, "password2") ...@@ -21,30 +21,38 @@ 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, "url70") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url70")
request_body = commonFuc().get_business_data(module, "payload70") request_body = commonFuc().get_business_data(module, "payload70")
# 发送请求 # 发送请求
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)
# 判断商品是否是控销商品
if result["data"]["list"][0]["isControlSales"] == 1: if result["data"]["list"][0]["isControlSales"] == 1:
# 获取控销商品信息
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")
password = commonFuc().get_business_data(module, "password") 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_headers7", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers7", 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, "payload7", product_id, price, filiale_code) request_body = commonFuc().get_business_data(module, "payload7", product_id, price, filiale_code)
""" """
场景:新增控销的商品至购物车列表 场景:新增控销的商品至购物车列表
用例名称:新增控销的商品至购物车列表 用例名称:新增控销的商品至购物车列表
输出:{"success":false,"code":"addBuyerCartFail","message":"商品为控销商品,不可加入购物车","data":null,"freshToken":null} 输出:{"success":false,"code":"addBuyerCartFail","message":"商品为控销商品,不可加入购物车","data":null,"freshToken":null}
""" """
# 发送请求 # 发送请求
result1 = requests.post(url1, json=request_body, headers=headers) result1 = requests.post(url1, json=request_body, headers=headers)
result1 = json.loads(result1.content) result1 = json.loads(result1.content)
......
...@@ -15,23 +15,27 @@ import json ...@@ -15,23 +15,27 @@ import json
module = "cmdc_buyercar_list" module = "cmdc_buyercar_list"
# 步骤一登录后台管理系统查询商品列表获取赠品且控销的商品信息 # 第一步登录后台管理系统查询商品列表获取赠品且控销的商品信息
# 获取登录后台管理系统所需账号密码 # 获取登录后台管理系统所需账号密码
username = commonFuc().get_business_data(module, "username2") username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password2") 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, "url110") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url110")
request_body = commonFuc().get_business_data(module, "payload110") request_body = commonFuc().get_business_data(module, "payload110")
# 发送请求 # 发送请求
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"]
# 第二步登录多采商城添加商品至购物车列表
# 第三步登录多采商城添加商品至购物车列表
# 获取登录多采商城所需账号密码 # 获取登录多采商城所需账号密码
username1 = commonFuc().get_business_data(module, "username") username1 = commonFuc().get_business_data(module, "username")
password1 = commonFuc().get_business_data(module, "password") password1 = commonFuc().get_business_data(module, "password")
...@@ -39,6 +43,8 @@ password1 = commonFuc().get_business_data(module, "password") ...@@ -39,6 +43,8 @@ password1 = commonFuc().get_business_data(module, "password")
cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token() cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token()
# print(cmdc_access_token) # print(cmdc_access_token)
headers1 = commonFuc().get_business_data(module, "json_headers11", cmdc_access_token1) headers1 = commonFuc().get_business_data(module, "json_headers11", cmdc_access_token1)
# 将商品添加至购物车列表
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body1 = commonFuc().get_business_data(module, "payload11", product_id, price, filiale_code) request_body1 = commonFuc().get_business_data(module, "payload11", product_id, price, filiale_code)
......
...@@ -14,29 +14,34 @@ import json ...@@ -14,29 +14,34 @@ import json
module = "cmdc_buyercar_list" module = "cmdc_buyercar_list"
# 步骤一登录后台管理系统查询商品列表获取赠品商品信息 # 第一步登录后台管理系统查询商品列表获取赠品商品信息
# 获取登录后台管理系统所需账号密码 # 获取登录后台管理系统所需账号密码
username = commonFuc().get_business_data(module, "username2") username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password2") 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, "url80") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url80")
request_body = commonFuc().get_business_data(module, "payload80") request_body = commonFuc().get_business_data(module, "payload80")
# 发送请求 # 发送请求
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"]
# 第二步登录多采商城添加商品至购物车列表
# 第三步登录多采商城添加商品至购物车列表
# 获取登录多采商城所需账号密码 # 获取登录多采商城所需账号密码
username1 = commonFuc().get_business_data(module, "username") username1 = commonFuc().get_business_data(module, "username")
password1 = commonFuc().get_business_data(module, "password") password1 = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token() cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token()
headers1 = commonFuc().get_business_data(module, "json_headers10", cmdc_access_token1) headers1 = commonFuc().get_business_data(module, "json_headers10", cmdc_access_token1)
# 将商品添加至购物车列表
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body1 = commonFuc().get_business_data(module, "payload8", product_id, price, filiale_code) request_body1 = commonFuc().get_business_data(module, "payload8", product_id, price, filiale_code)
......
...@@ -14,14 +14,15 @@ import json ...@@ -14,14 +14,15 @@ import json
module = "cmdc_buyercar_list" module = "cmdc_buyercar_list"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url)
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password") 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_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
# 将商品1添加至购物车列表
request_body1 = commonFuc().get_business_data(module, "payload300") request_body1 = commonFuc().get_business_data(module, "payload300")
# 发送请求 # 发送请求
result1 = requests.post(url, json=request_body1, headers=headers) result1 = requests.post(url, json=request_body1, headers=headers)
...@@ -30,7 +31,10 @@ result1 = json.loads(result1.content) ...@@ -30,7 +31,10 @@ result1 = json.loads(result1.content)
check_dict1 = commonFuc().get_business_data(module, "checkDict300") check_dict1 = commonFuc().get_business_data(module, "checkDict300")
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict1, result1) commonFuc().check_result(check_dict1, result1)
# 将商品2添加至购物车列表
request_body = commonFuc().get_business_data(module, "payload301") request_body = commonFuc().get_business_data(module, "payload301")
""" """
场景:新增跨站点商品至购物车列表 场景:新增跨站点商品至购物车列表
用例名称:新增跨站点商品至购物车列表 用例名称:新增跨站点商品至购物车列表
......
...@@ -27,7 +27,8 @@ request_body = commonFuc().get_business_data(module, "payload100") ...@@ -27,7 +27,8 @@ request_body = commonFuc().get_business_data(module, "payload100")
# 发送请求 # 发送请求
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)
# print(result)
# 获取商品信息
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"]
...@@ -39,6 +40,8 @@ password1 = commonFuc().get_business_data(module, "password") ...@@ -39,6 +40,8 @@ password1 = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token() cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token()
headers1 = commonFuc().get_business_data(module, "json_headers10", cmdc_access_token1) headers1 = commonFuc().get_business_data(module, "json_headers10", cmdc_access_token1)
# 将商品添加至购物车列表
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body1 = commonFuc().get_business_data(module, "payload10", product_id, price, filiale_code) request_body1 = commonFuc().get_business_data(module, "payload10", product_id, price, filiale_code)
......
...@@ -15,15 +15,17 @@ import json ...@@ -15,15 +15,17 @@ import json
module = "cmdc_buyercar_list" module = "cmdc_buyercar_list"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
print(url)
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password") 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_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 获取购物车列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body = commonFuc().get_business_data(module, "payload1") request_body = commonFuc().get_business_data(module, "payload1")
""" """
场景:获取到登录用户对应的购物车列表 场景:获取到登录用户对应的购物车列表
用例名称:获取购物车列表 用例名称:获取购物车列表
......
...@@ -28,11 +28,15 @@ password1 = commonFuc().get_business_data(module, "password1") ...@@ -28,11 +28,15 @@ password1 = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username1, password1).get_token() cmdc_access_token = CmdcDoLogin(username1, password1).get_token()
headers1 = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers1 = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 获取商品列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url20") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url20")
request_body = commonFuc().get_business_data(module, "payload20") request_body = commonFuc().get_business_data(module, "payload20")
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers1) result = requests.post(url, json=request_body, headers=headers1)
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"]
...@@ -40,12 +44,14 @@ filiale_code = result["data"]["list"][0]["filialeCode"] ...@@ -40,12 +44,14 @@ filiale_code = result["data"]["list"][0]["filialeCode"]
# 第二步在购物车中新增商品 # 第二步在购物车中新增商品
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body1 = commonFuc().get_business_data(module, "payload2", product_id, price, filiale_code) request_body1 = commonFuc().get_business_data(module, "payload2", product_id, price, filiale_code)
# 发送请求
result1 = requests.post(url1, json=request_body1, headers=headers) result1 = requests.post(url1, json=request_body1, headers=headers)
result1 = json.loads(result1.content) result1 = json.loads(result1.content)
# 第三步查询购物车中新增的商品信息 # 第三步查询购物车中新增的商品信息
url2 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1") url2 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body2 = commonFuc().get_business_data(module, "payload1") request_body2 = commonFuc().get_business_data(module, "payload1")
# 发送请求
result2 = requests.post(url2, json=request_body2, headers=headers) result2 = requests.post(url2, json=request_body2, headers=headers)
result2 = json.loads(result2.content) result2 = json.loads(result2.content)
# print(result2) # print(result2)
......
...@@ -29,12 +29,13 @@ request_body = commonFuc().get_business_data(module, "payload1") ...@@ -29,12 +29,13 @@ request_body = commonFuc().get_business_data(module, "payload1")
# 发送请求 # 发送请求
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)
# print(result) # 获取商品信息
invalid_sign = result["data"]["list"][0]["list"][0]["invalidSign"] invalid_sign = result["data"]["list"][0]["list"][0]["invalidSign"]
buyercart_id = result["data"]["list"][0]["list"][0]["buyerCartId"] buyercart_id = result["data"]["list"][0]["list"][0]["buyerCartId"]
product_name = result["data"]["list"][0]["list"][0]["productName"] product_name = result["data"]["list"][0]["list"][0]["productName"]
quantity = result["data"]["list"][0]["list"][0]["quantity"] quantity = result["data"]["list"][0]["list"][0]["quantity"]
modify_quantity = random.randint(2, 10) modify_quantity = random.randint(2, 10)
if invalid_sign == 0: if invalid_sign == 0:
# 组装修改购物车报文 # 组装修改购物车报文
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url83") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url83")
......
...@@ -22,11 +22,14 @@ password = commonFuc().get_business_data(module, "password1") ...@@ -22,11 +22,14 @@ password = commonFuc().get_business_data(module, "password1")
# 获取登录后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, "url20") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url20")
request_body = commonFuc().get_business_data(module, "payload20") request_body = commonFuc().get_business_data(module, "payload20")
# 发送请求 # 发送请求
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"]
...@@ -38,8 +41,10 @@ password1 = commonFuc().get_business_data(module, "password") ...@@ -38,8 +41,10 @@ password1 = commonFuc().get_business_data(module, "password")
cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token() cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token()
headers1 = commonFuc().get_business_data(module, "json_headers2", cmdc_access_token1) headers1 = commonFuc().get_business_data(module, "json_headers2", cmdc_access_token1)
# print(headers1) # print(headers1)
# 添加商品至购物车列表
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body1 = commonFuc().get_business_data(module, "payload2", product_id, price, filiale_code) request_body1 = commonFuc().get_business_data(module, "payload2", product_id, price, filiale_code)
""" """
场景:添加商品至用户购物车列表 场景:添加商品至用户购物车列表
用例名称:添加商品至用户购物车列表 用例名称:添加商品至用户购物车列表
......
...@@ -25,6 +25,7 @@ headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_tok ...@@ -25,6 +25,7 @@ headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_tok
url_batch = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_batch") url_batch = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_batch")
# 组装请求报文 # 组装请求报文
request_body = commonFuc().get_business_data(module, "payload22") request_body = commonFuc().get_business_data(module, "payload22")
""" """
场景:通过Excel复制添加商品时,不传产品信息,添加失败 场景:通过Excel复制添加商品时,不传产品信息,添加失败
用例名称:通过Excel复制添加商品时,不传产品信息,添加失败 用例名称:通过Excel复制添加商品时,不传产品信息,添加失败
......
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