Commit e7c3c9bf authored by liguangyu06's avatar liguangyu06
Browse files

业务场景验证:cmdc列表查询条件验证_发货时间列表

1 merge request!5Master|更新商品模块和订单逆向模块用例
Showing with 114 additions and 3 deletions
+114 -3
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_发货时间列表,2293,2293-035,sit,bs
主数据平台:运营后台管理系统发货时间列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
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, "url34")
request_body = commonFuc().get_business_data(module, "payload34")
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数
delivery_time_random = random.randint(0, len(result["data"]["list"]) - 1)
# 判断商品圈定方式
if result["data"]["list"][delivery_time_random]["productRangeType"]:
# 当商品圈定方式为按商品时,进行商品相关字段查询验证
delivery_time_id = result["data"]["list"][delivery_time_random]["deliveryTimeId"]
# 通过查看发货时间详情获取商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url36")
request_body = commonFuc().get_business_data(module, "payload36", delivery_time_id)
# 发送请求
result1 = requests.get(url, params=request_body, headers=headers)
result1 = json.loads(result1.content)
# 获取商品信息
line_codes = ""
name = result1["data"]["list"][delivery_time_random]["name"]
status = result1["data"]["list"][delivery_time_random]["status"]
product_code = result1["data"]["list"][delivery_time_random]["productList"][0]["productCode"]
product_name = result1["data"]["list"][delivery_time_random]["productList"][0]["productName"]
# 进行查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35")
request_body = commonFuc().get_business_data(module, "payload35", line_codes, name, status, product_code,
product_name)
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取查询结果中规则名称
result = {"name": result["data"]["list"][0]["name"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict35", name)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 当商品圈定方式为按产品线时,进行产品线相关字段查询验证
line_codes = result["data"]["list"][delivery_time_random]["lineCodes"]
name = result["data"]["list"][delivery_time_random]["name"]
status = result["data"]["list"][delivery_time_random]["status"]
product_code = ""
product_name = ""
# 进行查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35")
request_body = commonFuc().get_business_data(module, "payload35", line_codes, name, status, product_code,
product_name)
"""
场景: 列表查询条件验证_发货时间列表
用例名称:列表查询条件验证_发货时间列表
输出:{"name":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取查询结果中规则名称
result = {"name": result["data"]["list"][0]["name"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict35", name)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -243,13 +243,25 @@ checkDict32: {"success":true,"code":"200","message":"OK","data":"success","fresh
checkDict33: {"success":true,"code":"200","message":"OK","data":"success"}
#测试场景三十四:获取发货时间
"url34": "/product/deliveryTime/list"
"payload34": {"companyCode":null,"lineCodes":null,"name":null,"status":null,"productCode":null,"productName":null,"pageStart":1,"pageSize":10}
#预期结果
checkDict34: {"success":true,"code":"200","message":"OK"}
#测试场景三十五:列表查询条件验证_发货时间列表
"url35": "/product/deliveryTime/list"
"payload35": {"companyCode":null,"lineCodes":"%s","name":"%s","status":"%s","productCode":"%s","productName":"%s","pageStart":1,"pageSize":10}
#预期结果
checkDict35: {"name":"%s"}
#测试场景三十六:查看发货时间详情
"url36": "/product/deliveryTime/selectOne"
"payload36": {"id":"%s"}
#预期结果
checkDict36: {"id":"%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