Commit e26cdf1d authored by liguangyu06's avatar liguangyu06
Browse files

用例新增:列表查询条件验证_商品附件列表

parent 45022760
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_商品附件列表,2293,2293-012,sit,bs
主数据平台:运营后台管理系统商品附件列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import datetime
import requests
import random
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, "url11")
request_body = commonFuc().get_business_data(module, "payload11")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数字,用于后续随机选择某一条商品信息
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取商品附件信息
product_line_code = result["data"]["list"][rebate_random]["productLineCode"]
file_name = result["data"]["list"][rebate_random]["fileName"]
enable_sign = result["data"]["list"][rebate_random]["enableSign"]
update_time = result["data"]["list"][rebate_random]["createTime"][:10]
# 获取当前时间作为创建时间和最近修改时间截止时间
end_time = datetime.datetime.now().strftime('%Y-%m-%d')
# 进行列表查询操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url12")
request_body = commonFuc().get_business_data(module, "payload12", product_line_code, update_time, end_time, file_name,
enable_sign)
"""
场景: 列表查询条件验证_商品附件列表
用例名称:列表查询条件验证_商品附件列表
输出:{"fileName":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取查询结果中商品对应的附件名称
result = {"fileName": result["data"]["list"][0]["fileName"]}
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict12", file_name)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -95,7 +95,11 @@ checkDict10: {"success":true,"code":"200","message":"OK"}
checkDict11: {"success":true,"code":"200","message":"OK"}
#测试场景十二:列表查询条件验证_商品附件列表
"url12": "/product/public/queryUploadProductFilePage"
"payload12": {"productLineCode":"%s","uploadTimeQuery":["%s","%s"],"fileName":"%s","enableSign":"%s","pageStart":1,"pageSize":10,"total":0}
#预期结果
checkDict12: {"fileName":"%s"}
......
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