Commit af90fc8b authored by liguangyu06's avatar liguangyu06
Browse files

用例新增:自动配货近效期设置更新验证

parent 51c8c3a3
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc自动配货近效期设置更新验证,32,32-25,sit,bs
主数据平台:后台运营系统自动配货近效期设置更新接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_32st"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username_102")
password = commonFuc().get_business_data(module, "password_102")
# 获取登录后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, "url24")
request_body = commonFuc().get_business_data(module, "payload24")
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
valid_random = random.randint(0, len(result["data"]) - 1)
# 获取近效期设置信息
valid_json = result["data"][valid_random]
lineCodesList = result["data"][valid_random]["lineCodes"].split(",")
# 进行报文更新
valid_json["lineCodesList"] = lineCodesList
# 第三步进行自动配货近效期设置新增或者更新操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url25")
request_body = [valid_json]
# print(request_body)
"""
场景: 获取自动配货近效期设置
用例名称:获取自动配货近效期设置
输出:{"total":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 将接口响应时间添加至result
result = json.loads(result.content)
# print(result)
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict25")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -21,7 +21,7 @@ password = commonFuc().get_business_data(module, "password_102")
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, "url24")
request_body = commonFuc().get_business_data(module, "payload24")
......
......@@ -173,7 +173,10 @@ checkDict23: {"total":"%s"}
#预期结果
checkDict24: {"total":"%s"}
#测试场景25:自动配货近效期设置更新验证
"url25": "/product/public/saveAll"
#预期结果
checkDict25: {"success":true,"code":"200","message":"OK","data":null,"freshToken":null}
......
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