Commit 6845223f authored by liguangyu06's avatar liguangyu06
Browse files

用例优化

parent f640d958
......@@ -53,6 +53,7 @@ result2 = json.loads(result2.content)
# 第三步查询购物车中新增的商品信息
url3 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body3 = commonFuc().get_business_data(module, "payload2")
# 发送请求
result3 = requests.post(url3, json=request_body3, headers=headers)
result3 = json.loads(result3.content)
# 获取购物车列表中商品对应的productId
......
......@@ -16,8 +16,6 @@ import random
module = "cmdc_frequent_purchase"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
print(url)
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
......@@ -26,6 +24,8 @@ cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers4", cmdc_access_token)
# 随机生成productId
product_id = random.randint(1000000000000, 100000000000000)
# 将商品添加至购物车列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body = commonFuc().get_business_data(module, "payload400", product_id)
"""
......@@ -37,9 +37,9 @@ request_body = commonFuc().get_business_data(module, "payload400", product_id)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict400")
print(check_dict)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -25,6 +25,7 @@ headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_tok
# 第二步切换至子站点
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2000")
request_body = commonFuc().get_business_data(module, "payload2000")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 添加商品至常购清单列表
......
......@@ -45,6 +45,7 @@ headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_tok
# 第三步切换至子站点
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2000")
request_body = commonFuc().get_business_data(module, "payload2001")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 第四步添加已失效商品至常购清单列表
......
......@@ -22,6 +22,7 @@ password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 查询商品列表获取控销商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url50")
request_body = commonFuc().get_business_data(module, "payload50")
......@@ -44,6 +45,7 @@ headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_tok
# 第三步切换至子站点
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2000")
request_body = commonFuc().get_business_data(module, "payload2001")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 第四步添加控销商品至常购清单列表
......
......@@ -44,6 +44,7 @@ headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_tok
# 第三步切换至子站点
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2000")
request_body = commonFuc().get_business_data(module, "payload2001")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 第四步添加赠品至常购清单列表
......
......@@ -57,6 +57,7 @@ headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_tok
# 切换至子站点
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2000")
request_body = commonFuc().get_business_data(module, "payload2001")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 添加已商品至常购清单列表
......@@ -81,6 +82,7 @@ commonFuc().check_result(check_dict, result)
# 切换至子站点
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2000")
request_body = commonFuc().get_business_data(module, "payload2002")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 添加商品至常购清单列表
......
......@@ -13,14 +13,16 @@ import json
module = "cmdc_frequent_purchase"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
# print(url)
# 获取登录所需账号密码
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_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")
request_body = commonFuc().get_business_data(module, "payload2")
"""
......
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