Commit e7e2bda7 authored by 李光宇's avatar 李光宇
Browse files

Merge branch 'master' into 'main'

Master|更新商品模块和订单逆向模块用例

See merge request !5
parents ffa18436 8fa1e69c
...@@ -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)
......
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc新增商品至购物车_商品超数量验证,2252,2252-1,sit,bs
主数据平台:多采商城购物车列表新增商品接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import requests
import json
module = "cmdc_buyercar_list"
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username")
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_headers4", cmdc_access_token)
# 添加商品至购物车列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body = commonFuc().get_business_data(module, "payload36")
"""
场景:新增商品至购物车_商品超数量验证
用例名称:新增商品至购物车_商品超数量验证
输出:{"success":false,"code":"1076","message":"该商品在购物车已达到最大数量,无法加入更多","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict36")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc新增商品至购物车_必填字段校验,2252,2252-1,sit,bs
主数据平台:多采商城购物车列表新增商品接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import requests
import json
module = "cmdc_buyercar_list"
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username")
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_headers4", cmdc_access_token)
# 添加商品至购物车列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body = commonFuc().get_business_data(module, "payload20")
"""
场景:新增商品至购物车_必填字段校验
用例名称:新增商品至购物车_必填字段校验
输出:{"success":false,"code":"1002","message":"参数不能为空","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict20")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc新增商品至购物车_站点不存在或者站点已下架,2252,2252-1,sit,bs
主数据平台:多采商城购物车列表新增商品接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import requests
import json
module = "cmdc_buyercar_list"
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username")
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_headers4", cmdc_access_token)
# 添加商品至购物车列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body = commonFuc().get_business_data(module, "payload35")
"""
场景:新增商品至购物车_站点不存在或者站点已下架
用例名称:新增商品至购物车_站点不存在或者站点已下架
输出:{"success":false,"code":"5000","message":"该商品不可加入购物车,站点直通车未开启,或者站点已经下架","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict35")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
...@@ -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")
......
...@@ -10,6 +10,7 @@ from common.common_func import commonFuc ...@@ -10,6 +10,7 @@ from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests import requests
import random
import json import json
...@@ -22,14 +23,21 @@ password = commonFuc().get_business_data(module, "password1") ...@@ -22,14 +23,21 @@ 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_1")
# 发送请求 # 发送请求
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"] # print(result)
price = result["data"]["list"][0]["referencePrice"]
filiale_code = result["data"]["list"][0]["filialeCode"] # 生成随机数
product_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取商品列表中的商品信息
product_id = result["data"]["list"][product_random]["productId"]
price = result["data"]["list"][product_random]["referencePrice"]
filiale_code = result["data"]["list"][product_random]["filialeCode"]
# 第二步登录多采商城添加商品至购物车列表 # 第二步登录多采商城添加商品至购物车列表
# 获取登录所需账号密码 # 获取登录所需账号密码
username1 = commonFuc().get_business_data(module, "username") username1 = commonFuc().get_business_data(module, "username")
...@@ -38,8 +46,10 @@ password1 = commonFuc().get_business_data(module, "password") ...@@ -38,8 +46,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)
""" """
场景:添加商品至用户购物车列表 场景:添加商品至用户购物车列表
用例名称:添加商品至用户购物车列表 用例名称:添加商品至用户购物车列表
...@@ -49,8 +59,15 @@ request_body1 = commonFuc().get_business_data(module, "payload2", product_id, pr ...@@ -49,8 +59,15 @@ request_body1 = commonFuc().get_business_data(module, "payload2", product_id, pr
result1 = requests.post(url1, json=request_body1, headers=headers1) result1 = requests.post(url1, json=request_body1, headers=headers1)
result1 = json.loads(result1.content) result1 = json.loads(result1.content)
# print(result1) # print(result1)
# 获取预期结果 if result1["success"]:
check_dict = commonFuc().get_business_data(module, "checkDict2") # 获取预期结果
# print(check_dict) check_dict = commonFuc().get_business_data(module, "checkDict2")
# 断言实际结果中是否包含预期结果的内容 # print(check_dict)
commonFuc().check_result(check_dict, result1) # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result1)
else:
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict7")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result1)
...@@ -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复制添加商品时,不传产品信息,添加失败
......
...@@ -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
# 第二步新增商品至购物车列表 # 第二步新增商品至购物车列表
url_add = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_add") url_add = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_add")
# 发送请求
request_body2 = commonFuc().get_business_data(module, "payload3") request_body2 = commonFuc().get_business_data(module, "payload3")
result2 = requests.post(url_add, json=request_body2, headers=headers) result2 = requests.post(url_add, json=request_body2, headers=headers)
...@@ -40,9 +41,9 @@ request_body = commonFuc().get_business_data(module, "payload8") ...@@ -40,9 +41,9 @@ request_body = commonFuc().get_business_data(module, "payload8")
# 发送请求 # 发送请求
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]["list"][0]["productId"]
# print(product_id) # 获取查询结果中商品id
result = {"productId": product_id} result = {"productId": result["data"]["list"][0]["list"][0]["productId"]}
# # 获取预期结果 # # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3") check_dict = commonFuc().get_business_data(module, "checkDict3")
......
...@@ -35,6 +35,7 @@ result2 = json.loads(result2.content) ...@@ -35,6 +35,7 @@ result2 = json.loads(result2.content)
check_dict1 = commonFuc().get_business_data(module, "checkDict1") check_dict1 = commonFuc().get_business_data(module, "checkDict1")
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict1, result2) commonFuc().check_result(check_dict1, result2)
""" """
场景:购物车支持跨站商品下单验证 场景:购物车支持跨站商品下单验证
用例名称:购物车支持跨站商品下单验证 用例名称:购物车支持跨站商品下单验证
...@@ -45,15 +46,21 @@ commonFuc().check_result(check_dict1, result2) ...@@ -45,15 +46,21 @@ commonFuc().check_result(check_dict1, result2)
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
# 获取102站点商品对应的id值 # 获取102站点商品对应的id值
request_body = commonFuc().get_business_data(module, "payload4") request_body = commonFuc().get_business_data(module, "payload4")
# 发送请求
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)
# 获取添加至购物车列表商品对应的buyerCartId
buyercart_id_102 = result["data"]["list"][0]["list"][0]["buyerCartId"] buyercart_id_102 = result["data"]["list"][0]["list"][0]["buyerCartId"]
# print(buyercart_id_102)
# 获取103站点商品对应的id值 # 获取103站点商品对应的id值
request_body = commonFuc().get_business_data(module, "payload5") request_body = commonFuc().get_business_data(module, "payload5")
# 发送请求
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)
# 获取添加至购物车列表商品对应的buyerCartId
buyercart_id_103 = result["data"]["list"][0]["list"][0]["buyerCartId"] buyercart_id_103 = result["data"]["list"][0]["list"][0]["buyerCartId"]
# 将获取到商品对应的buyerCartId添加至同一个字典中,便于后续传参
buyercart_its = [buyercart_id_102, buyercart_id_103] buyercart_its = [buyercart_id_102, buyercart_id_103]
# 第四步,进行商品的选择 # 第四步,进行商品的选择
......
...@@ -15,8 +15,8 @@ module = "cmdc_coupon" ...@@ -15,8 +15,8 @@ module = "cmdc_coupon"
# 第一步登录后台运营平台获取cmdc_access_token # 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username3") username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password3") 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)
......
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