Commit 7608cfbd authored by liguangyu06's avatar liguangyu06
Browse files

用例优化

parent 7b2c3276
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc商品限购金额配置编辑修改功能验证,2293,2293-84,sit,bs
主数据平台:运营后台管理系统商品限购金额配置编辑接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_product"
# 获取登录所需账号密码
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()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 获取商品限购金额列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url81")
request_body = commonFuc().get_business_data(module, "payload81")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取限购金额配置信息
productCode = result["data"]["list"][::-1][0]["productCode"]
customerCode = result["data"]["list"][::-1][0]["customerCode"]
takeEffectTime = result["data"]["list"][::-1][0]["takeEffectTime"]
endTime = result["data"]["list"][::-1][0]["endTime"]
id = result["data"]["list"][::-1][0]["id"]
limitBuyAmount = result["data"]["list"][::-1][0]["limitBuyAmount"]
# 对商品限购金额配置编辑操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url84")
request_body = commonFuc().get_business_data(module, "payload84", productCode, customerCode, takeEffectTime, endTime,
id, limitBuyAmount)
"""
场景: 商品限购金额配置编辑修改功能验证
用例名称:商品限购金额配置编辑修改功能验证
输出:{"success":true,"code":"200","message":null,"data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 将接口响应时间添加至result
result = json.loads(result.content)
result["api_time"] = api_time
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict84")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -599,10 +599,12 @@ checkDict82: {"success":true,"code":"200","message":null,"data":null,"freshToken
"payload82_2": {"customerCode":null,"customerName":null,"pageSize":null,"pageNum":null,"total":null}
#测试场景八十三:商品限购金额配置删除操作
"url83": "/product/productLimitBuy/del"
"payload83": {"ids":"%s"}
checkDict83: {"success":true,"code":"200","message":"OK","data":true}
#测试场景八十四:商品限购金额配置编辑修改功能验证
"url84": "/product/public/updateProductLimit"
"payload84": {"productCode":"%s","customerCode":"%s","takeEffectTime":"%s","endTime":"%s","limitType":"1","id":"%s","limitBuyAmount":"%s"}
checkDict84: {"success":true,"code":"200","message":null,"data":null,"freshToken":null}
\ No newline at end of file
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