Commit fa38ebde authored by liguangyu06's avatar liguangyu06
Browse files

新增套包协议特价相关用例

parent a7cb998c
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc停用_套包协议特价,2264,2264-53,sit,bs
主数据平台:运营后台管理系统套包协议特价列表查询接口和停用接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.db.db import mySql
import requests
import json
module = "cmdc_special_fresenius_group"
# 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码
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_headers2", cmdc_access_token)
# 第二步套包协议特价列表查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url36")
request_body = commonFuc().get_business_data(module, "payload36")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取套包协议特价id
fresenius_price_id = result["data"]["list"][0]["freseniusPriceId"]
# 第三步进行套包协议特价停用操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url37")
request_body = {"freseniusPriceIds": [fresenius_price_id], "groupPriceStatus": 0, "remarks": "套包协议特价停用功能验证"}
"""
场景: 停用_套包协议特价
用例名称:停用_套包协议特价
输出:{"groupPriceStatus": 0}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询特价单品数量
sql = "SELECT t.groupPriceStatus FROM `cmdc-order`.tc_fresenius_agreement_price t WHERE freseniusPriceId = {};".format(fresenius_price_id)
result = {"groupPriceStatus": mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]}
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict19")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc单个新增验证_套包协议特价,2264,2264-56,sit,bs
主数据平台:后台运营系统客户列表查询、套包列表查询、套包协议特价新增等接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from datetime import timedelta, date
import random
import requests
import uuid
import json
module = "cmdc_special_fresenius_group"
# 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码
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, "customer_list_url")
request_body = commonFuc().get_business_data(module, "customer_payload")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
customer_quantity = random.randint(1, len(result["data"]["list"]) - 1)
# 客户信息获取
customer_code = result["data"]["list"][customer_quantity]["customerCode"]
customer_name = result["data"]["list"][customer_quantity]["customerName"]
user_name = result["data"]["list"][customer_quantity]["userName"]
# 第三步套包获取
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url25")
request_body = commonFuc().get_business_data(module, "payload25")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成套包随机数
group_quantity = random.randint(1, len(result["data"]["list"]) - 1)
# 获取套包信息
fresenius_group = result["data"]["list"][group_quantity]
product_json = result["data"]["list"][group_quantity]["products"]
group_code = result["data"]["list"][group_quantity]["groupCode"]
group_name = result["data"]["list"][group_quantity]["groupName"]
id = result["data"]["list"][group_quantity]["products"][0]["id"]
product_code = result["data"]["list"][group_quantity]["products"][0]["productCode"]
product_name = result["data"]["list"][group_quantity]["products"][0]["productName"]
manufacturer = result["data"]["list"][group_quantity]["products"][0]["manufacturer"]
manufacturer_code = result["data"]["list"][group_quantity]["products"][0]["manufacturerCode"]
option_str = result["data"]["list"][group_quantity]["products"][0]["optionStr"]
measuring_unit = result["data"]["list"][group_quantity]["products"][0]["measuringUnit"]
material_code = result["data"]["list"][group_quantity]["products"][0]["materialCode"]
quantity = result["data"]["list"][group_quantity]["products"][0]["quantity"]
# 随机生成日期
start_date = date(2000, 1, 1)
end_date = date.today()
def random_date(start, end):
delta = end - start
random_days = random.randint(0, delta.days)
return start + timedelta(days=random_days)
random_date = random_date(start_date, end_date)
# 随机生成唯一字符串用于ref
ref_random = str(uuid.uuid4())
# 生成促销价格
activity_unit_amount = random.randint(10, 10000)
# 生成套包说明
group_str = ""
for i in product_json:
# 更新套包内每个商品活动价格
i.update({"activityUnitAmount": activity_unit_amount})
# 获取套包内包含商品信息
product_name = i["productName"]
option_str = i["optionStr"]
quantity = i["quantity"]
str1 = "{}({})*{}".format(product_name, option_str, quantity)
group_str = str1 + "+" + group_str
# 生成套包说明
group_str = "平台套包编号:{} || 套包名称:{}({})".format(group_code, group_name, group_str)
# 更新请求报文中活动价格
fresenius_group.update({"products": product_json})
# 报文组装
fresenius_group.update(commonFuc().get_business_data(module, "payload32", id, product_code, product_name, manufacturer,
manufacturer_code, option_str, measuring_unit, material_code,
quantity))
# 第四步套包协议特价新增
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35")
request_body = {"manufacturerGroupName": "", "manufacturerGroupCode": "", "groupName": "", "limitPurchase": "",
"isLimit": 0, "freseniusGroup": fresenius_group, "groupStr": group_str, "customerCode": customer_code,
"userName": user_name, "customerName": customer_name, "documentNo": ref_random,
"time": [str(start_date), str(random_date)], "effectiveTime": str(start_date), "expirationTime": str(random_date)}
print(request_body)
"""
场景: 单个新增验证_套包协议特价
用例名称:单个新增验证_套包协议特价
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict20")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
import random
"""
case_tag:cmdc_api,cmdc特价单品新增功能验证,2264,2264-60,sit,bs
主数据平台:后台运营系统客户列表查询、商品列表查询、特价单品新增等接口
......
......@@ -219,3 +219,19 @@ checkDict31: {"groupCode": "%s"}
"payload32": {"freseniusPriceId":null,"customerCode":null,"customerName":null,"isLimit":null,"isRegularPrice":null,"limitPurchase":null,"groupPrice":null,"effectiveTime":null,"expirationTime":null,"documentNo":null,"salesArea":null,"salesProvince":null,"supplementNo":null,"applicationType":null,"manufacturerUserDesc":null,"manufacturerUserNo":null,"manufacturerUserType":null,"groupPriceStatus":null,"surplusQuantity":null,"freseniusGroup":null,"id":"%d","productCode":"%s","productName":"%s","manufacturer":"%s","manufacturerCode":"%s","optionStr":"%s","activityUnitAmount":null,"price":null,"measuringUnit":"%s","materialCode":"%s","description":"","quantity":"%d","manufacturerProductNo":null,"manufacturerProductDesc":null,"produceRegisterNum":null,"storageCondition":null,"productCodeList":null,"storageType":null,"productId":null,"productNature":null,"brandName":null,"imageUrl":null,"riskRank":null,"productClassify":null,"rowspan":2,"colspan":1}
#测试场景:套包正价管理(指定客户)单个新增功能验证
"url31": "/order/public/saveRegularFreseniusPrice"
#测试场景:单个新增验证_套包协议特价
"url35": "/order/public/saveFreseniusAgreementPrice"
#测试场景:套包协议特价停用功能验证
#套包协议特价列表接口和报文
"url36": "/order/public/queryFreseniusAgreementPricePageInfo"
"payload36": {"groupCode":"","groupName":"","productCode":"","productInfo":"","materialCode":"","manufacturerList":[],"productLineName":"","description":"","manufacturerProductDesc":"","manufacturerProductNo":"","customerCode":"","customerName":"","manufacturerUserNo":"","manufacturerUserDesc":"","documentNo":"","companyCode":"","groupType":0,"status":null,"pageStart":1,"pageSize":10,"groupPriceStatus":"1"}
#套包协议特价停用
"url37": "/order/public/enableOrDisablePrice"
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