Commit 681269eb authored by liguangyu06's avatar liguangyu06
Browse files

优化

parent 4a49c4db
......@@ -19,15 +19,15 @@ 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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 第二步查询站点对应的companyId
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
print(url1)
request_body1 = commonFuc().get_business_data(module, "payload1")
print(request_body1)
result1 = requests.post(url1, json=request_body1, headers=headers)
result1 = json.loads(result1.text)
......@@ -40,40 +40,30 @@ result1 = json.loads(result1.text)
# 获取站点对应的快速下单标识字段quickOrderSign
result1 = result1["data"]
print(result1)
for i in result1:
quick_order_sign = i["quickOrderSign"]
print(quick_order_sign)
# 第三步验证站点是否具有快速下单权限
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
print(url)
if quick_order_sign == 0:
# 获取companyId
company_id = i["companyId"]
print(company_id)
request_body = commonFuc().get_business_data(module, "payload", company_id)
print(request_body)
result = requests.get(url, params=request_body)
result = json.loads(result.text)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
break
else:
# 获取companyId
company_id = i["companyId"]
print(company_id)
request_body = commonFuc().get_business_data(module, "payload", company_id)
print(request_body)
result = requests.get(url, params=request_body)
result = json.loads(result.text)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
break
......
......@@ -19,21 +19,15 @@ 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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 第二步查询站点对应的companyId
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
print(url1)
request_body1 = commonFuc().get_business_data(module, "payload1")
print(request_body1)
result1 = requests.post(url1, json=request_body1, headers=headers)
result1 = json.loads(result1.text)
print(result1)
# 获取站点对应的快速下单标识字段quickOrderSign
quick_order_sign = result1["data"][0]["quickOrderSign"]
print(quick_order_sign)
"""
场景:站点拥有快速下单权限入口
......@@ -44,33 +38,25 @@ print(quick_order_sign)
# 第三步验证站点是否具有快速下单权限
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
print(url)
if quick_order_sign == "1":
# 获取companyId
company_id = result1["data"][0]["companyId"]
print(company_id)
request_body = commonFuc().get_business_data(module, "payload", company_id)
print(request_body)
result = requests.get(url, params=request_body)
result = json.loads(result.text)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 获取companyId
company_id = result1["data"][0]["companyId"]
print(company_id)
request_body = commonFuc().get_business_data(module, "payload", company_id)
print(request_body)
result = requests.get(url, params=request_body)
result = json.loads(result.text)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -16,17 +16,13 @@ module = "cmdc_buyercar_list"
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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers4", cmdc_access_token)
print(headers)
request_body = commonFuc().get_business_data(module, "payload4")
print(request_body)
"""
场景:新增不存在的商品至购物车列表
用例名称:新增不存在的商品至购物车列表
......@@ -35,10 +31,8 @@ print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict4")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -21,34 +21,23 @@ username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url50")
print(url)
request_body = commonFuc().get_business_data(module, "payload50")
print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
product_id = result["data"]["list"][0]["productId"]
print(product_id)
price = result["data"]["list"][0]["referencePrice"]
print(price)
# 第二步登录多彩商城添加商品至购物车列表
# 获取登录多彩商城所需账号密码
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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers5", cmdc_access_token)
print(headers)
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url1)
request_body = commonFuc().get_business_data(module, "payload5", product_id, price)
print(request_body)
"""
场景:新增已失效的商品至购物车列表
用例名称:新增已失效的商品至购物车列表
......@@ -57,9 +46,7 @@ print(request_body)
# 发送请求
result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict5")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -12,7 +12,6 @@ from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 impor
import requests
import json
module = "cmdc_buyercar_list"
# 步骤一登录后台管理系统查询控销商品列表获取已下架商品信息
......@@ -21,46 +20,35 @@ username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 查询控销商品列表获取已下架商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url70")
print(url)
request_body = commonFuc().get_business_data(module, "payload70")
print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
if result["data"]["list"][0]["isControlSales"] == 1:
product_id = result["data"]["list"][0]["productId"]
print(product_id)
price = result["data"]["list"][0]["referencePrice"]
print(price)
# 第二步登录多彩商城添加商品至购物车列表
# 获取登录多彩商城所需账号密码
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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers7", cmdc_access_token)
print(headers)
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url1)
request_body = commonFuc().get_business_data(module, "payload7", product_id, price)
print(request_body)
"""
场景:新增控销的商品至购物车列表
用例名称:新增控销的商品至购物车列表
输出:{"success":false,"code":"addBuyerCartFail","message":"商品为控销商品,不可加入购物车","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
result1 = requests.post(url1, json=request_body, headers=headers)
result1 = json.loads(result1.content)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict7")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
\ No newline at end of file
commonFuc().check_result(check_dict, result1)
......@@ -21,34 +21,25 @@ username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 查询商品列表获取赠品且控销的商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url110")
print(url)
request_body = commonFuc().get_business_data(module, "payload110")
print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
product_id = result["data"]["list"][0]["productId"]
print(product_id)
price = result["data"]["list"][0]["referencePrice"]
print(price)
# 第二步登录多彩商城添加商品至购物车列表
# 获取登录多彩商城所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
username1 = commonFuc().get_business_data(module, "username")
password1 = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers11", cmdc_access_token)
print(headers)
headers1 = commonFuc().get_business_data(module, "json_headers11", cmdc_access_token1)
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url1)
request_body = commonFuc().get_business_data(module, "payload11", product_id, price)
print(request_body)
request_body1 = commonFuc().get_business_data(module, "payload11", product_id, price)
"""
场景:添加赠品且控销的商品至购物车列表
......@@ -56,11 +47,9 @@ print(request_body)
输出:{"success":false,"code":"addBuyerCartFail","message":"商品为控销商品,不可加入购物车","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
result1 = requests.post(url1, json=request_body1, headers=headers1)
result1 = json.loads(result1.content)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict11")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
commonFuc().check_result(check_dict, result1)
......@@ -21,34 +21,24 @@ username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 查询商品列表获取赠品商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url80")
print(url)
request_body = commonFuc().get_business_data(module, "payload80")
print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
product_id = result["data"]["list"][0]["productId"]
print(product_id)
price = result["data"]["list"][0]["referencePrice"]
print(price)
# 第二步登录多彩商城添加商品至购物车列表
# 获取登录多彩商城所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
username1 = commonFuc().get_business_data(module, "username")
password1 = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers10", cmdc_access_token)
print(headers)
cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token()
headers1 = commonFuc().get_business_data(module, "json_headers10", cmdc_access_token1)
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url1)
request_body = commonFuc().get_business_data(module, "payload8", product_id, price)
print(request_body)
request_body1 = commonFuc().get_business_data(module, "payload8", product_id, price)
"""
场景:添加赠品至购物车列表
......@@ -56,11 +46,9 @@ print(request_body)
输出:{"success":true,"code":"200","message":"OK","data":"ok"}
"""
# 发送请求
result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
result1 = requests.post(url1, json=request_body1, headers=headers1)
result1 = json.loads(result1.content)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict8")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
commonFuc().check_result(check_dict, result1)
......@@ -21,25 +21,16 @@ 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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
print(headers)
request_body1 = commonFuc().get_business_data(module, "payload300")
print(request_body1)
# 发送请求
result1 = requests.post(url, json=request_body1, headers=headers)
result1 = json.loads(result1.content)
print(result1)
# 获取预期结果
check_dict1 = commonFuc().get_business_data(module, "checkDict300")
print(check_dict1)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict1, result1)
request_body = commonFuc().get_business_data(module, "payload301")
print(request_body)
"""
场景:新增跨站点商品至购物车列表
用例名称:新增跨站点商品至购物车列表
......@@ -48,9 +39,7 @@ print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict300")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
\ No newline at end of file
......@@ -12,7 +12,6 @@ from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 impor
import requests
import json
module = "cmdc_buyercar_list"
# 步骤一登录后台管理系统查询商品列表获取添加JDE已停用商品信息
......@@ -21,34 +20,24 @@ username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 查询商品列表获取添加JDE已停用商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url100")
print(url)
request_body = commonFuc().get_business_data(module, "payload100")
print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
product_id = result["data"]["list"][0]["productId"]
print(product_id)
price = result["data"]["list"][0]["referencePrice"]
print(price)
# 第二步登录多彩商城添加商品至购物车列表
# 获取登录多彩商城所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
username1 = commonFuc().get_business_data(module, "username")
password1 = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers10", cmdc_access_token)
print(headers)
cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token()
headers1 = commonFuc().get_business_data(module, "json_headers10", cmdc_access_token1)
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url1)
request_body = commonFuc().get_business_data(module, "payload10", product_id, price)
print(request_body)
request_body1 = commonFuc().get_business_data(module, "payload10", product_id, price)
"""
场景:添加JDE已停用的商品至购物车列表
......@@ -56,11 +45,9 @@ print(request_body)
输出:{"success":false,"code":"addBuyerCartFail","message":"商品为失效状态,不可加入购物车","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
result1 = requests.post(url1, json=request_body1, headers=headers1)
result1 = json.loads(result1.content)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict10")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
\ No newline at end of file
commonFuc().check_result(check_dict, result1)
......@@ -22,11 +22,8 @@ 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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
print(headers)
request_body = commonFuc().get_business_data(module, "payload1")
print(request_body)
"""
场景:获取到登录用户对应的购物车列表
用例名称:获取购物车列表
......@@ -35,9 +32,7 @@ print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -19,38 +19,25 @@ 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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers3", cmdc_access_token)
print(headers)
# 第二步在购物车中新增商品
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url1)
request_body = commonFuc().get_business_data(module, "payload2")
print(request_body)
result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
request_body1 = commonFuc().get_business_data(module, "payload2")
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")
print(url2)
request_body = commonFuc().get_business_data(module, "payload1")
print(request_body)
result = requests.post(url2, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
request_body2 = commonFuc().get_business_data(module, "payload1")
result2 = requests.post(url2, json=request_body2, headers=headers)
result2 = json.loads(result2.content)
# 获取所添加商品id
product_id = commonFuc().get_business_data(module, "payload2")["productId"]
print(product_id, type(product_id))
result_product_id = result["data"]["list"][0]["list"][0]["productId"]
print(result_product_id, type(result_product_id))
result_product_id = result2["data"]["list"][0]["list"][0]["productId"]
if result_product_id == product_id:
buyer_cart_id = result["data"]["list"][0]["list"][0]["buyerCartId"]
print(buyer_cart_id)
buyer_cart_id = result2["data"]["list"][0]["list"][0]["buyerCartId"]
request_body = commonFuc().get_business_data(module, "payload3", buyer_cart_id)
print(request_body)
# 第三步删除新增加至购物车列表的商品
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3")
print(url)
"""
场景:从用户购物车列表移除商品
用例名称:从用户购物车列表移除商品
......@@ -59,9 +46,7 @@ if result_product_id == product_id:
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
import random
"""
case_tag:cmdc_api,cmdc购物车数量修改验证,2252,2252-4,sit,bs
主数据平台:多彩商城修改购物车中商品数量接口
......@@ -24,57 +22,40 @@ 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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
print(headers)
# 获取购物车列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
print(url)
request_body = commonFuc().get_business_data(module, "payload1")
print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
invalid_sign = result["data"]["list"][0]["list"][0]["invalidSign"]
buyercart_id = result["data"]["list"][0]["list"][0]["buyerCartId"]
product_name = result["data"]["list"][0]["list"][0]["productName"]
quantity = result["data"]["list"][0]["list"][0]["quantity"]
print(invalid_sign, buyercart_id, product_name)
modify_quantity = random.randint(1, 10)
print(modify_quantity)
print(invalid_sign)
if invalid_sign == 0:
print("=========123=========")
# 组装修改购物车报文
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url80")
print(url1)
request_body1 = commonFuc().get_business_data(module, "payload80", buyercart_id, quantity)
print(request_body1)
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url83")
request_body1 = commonFuc().get_business_data(module, "payload83", buyercart_id, quantity)
# 发送请求
result1 = requests.post(url1, json=request_body1, headers=headers)
result1 = json.loads(result1.content)
print(result1)
# 获取预期结果
check_dict1 = commonFuc().get_business_data(module, "checkDict80")
print(check_dict1)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict1, result1)
# 获取购物车列表
url2 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
print(url2)
request_body2 = commonFuc().get_business_data(module, "payload81", product_name)
print(request_body2)
# 发送请求
result2 = requests.post(url2, json=request_body2, headers=headers)
result2 = json.loads(result2.content)
print(result2)
for i in result2["data"]["list"][0]["list"]:
if i["buyerCartId"] == buyercart_id:
result3 = i["quantity"]
check_dict3 = commonFuc().get_business_data(module, "checkDict81", result3)
check_dict4 = commonFuc().get_business_data(module, "checkDict82", quantity)
print(check_dict4, check_dict3)
commonFuc().check_result(check_dict3, check_dict4)
"""
......
......@@ -21,45 +21,32 @@ username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url20")
print(url)
request_body = commonFuc().get_business_data(module, "payload20")
print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
product_id = result["data"]["list"][0]["productId"]
print(product_id)
price = result["data"]["list"][0]["referencePrice"]
print(price)
# 第二步登录多彩商城添加商品至购物车列表
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
username1 = commonFuc().get_business_data(module, "username")
password1 = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers2", cmdc_access_token)
print(headers)
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url)
request_body = commonFuc().get_business_data(module, "payload2", product_id, price)
print(request_body)
cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token()
headers1 = commonFuc().get_business_data(module, "json_headers2", cmdc_access_token1)
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body1 = commonFuc().get_business_data(module, "payload2", product_id, price)
"""
场景:添加商品至用户购物车列表
用例名称:添加商品至用户购物车列表
输出:{"success":true,"code":"200","message":"OK","data":"ok"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
result1 = requests.post(url1, json=request_body1, headers=headers1)
result1 = json.loads(result1.content)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
commonFuc().check_result(check_dict, result1)
......@@ -21,15 +21,10 @@ username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 第二步查询商品信息管理中已失效商品
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
print(url)
request_body = commonFuc().get_business_data(module, "payload1")
print(request_body)
"""
场景:查询已失效商品信息
用例名称:查询已失效商品信息
......@@ -39,9 +34,7 @@ print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -21,15 +21,10 @@ username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 第二步查询商品信息管理中已上架商品
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url)
request_body = commonFuc().get_business_data(module, "payload2")
print(request_body)
"""
场景:查询已上架商品信息
用例名称:查询已上架商品信息
......@@ -39,9 +34,7 @@ print(request_body)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -21,15 +21,11 @@ username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 第二步查询商品信息管理中控销商品
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3")
print(url)
request_body = commonFuc().get_business_data(module, "payload3")
print(request_body)
"""
场景:查询控销商品信息
用例名称:查询控销商品信息
......
......@@ -21,15 +21,10 @@ username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
# 第二步查询商品信息管理中赠品
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url4")
print(url)
request_body = commonFuc().get_business_data(module, "payload4")
print(request_body)
"""
场景:查询赠品信息
用例名称:查询赠品信息
......
......@@ -20,11 +20,8 @@ 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()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
print(headers)
request_body = commonFuc().get_business_data(module, "payload")
print(request_body)
"""
场景:通过快速下单入口提交创建需求单
用例名称:通过快速下单入口提交创建需求单
......
......@@ -21,12 +21,8 @@ username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
# cmdc_access_token = CmdcDoLogin("admin2", "FFtmods@365y").get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers1",cmdc_access_token)
print(headers)
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
request_body = commonFuc().get_business_data(module, "payload1")
print(request_body)
"""
场景:需求创建
用例名称:需求单创建
......
......@@ -11,7 +11,6 @@ from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 impor
import requests
import json
module = "cmdc_demand_creation"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
......@@ -21,17 +20,15 @@ username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
# cmdc_access_token = CmdcDoLogin("admin2", "FFtmods@365y").get_token()
print(cmdc_access_token)
headers = commonFuc().get_business_data(module, "json_headers1",cmdc_access_token)
print(headers)
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
request_body = commonFuc().get_business_data(module, "payload1")
print(request_body)
"""
场景:需求草稿订单的创建
用例名称:需求草稿订单的创建
输出:{"success":true,"code":"200","message":"ok","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
......@@ -40,4 +37,4 @@ print(result)
check_dict = commonFuc().get_business_data(module, "checkDict1")
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
\ No newline at end of file
commonFuc().check_result(check_dict, result)
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