Commit c9176154 authored by 李光宇's avatar 李光宇
Browse files

Merge branch 'master' into 'main'

用例优化及合并返利模块用例

See merge request !3
parents 1587d6ac d86802c2
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_客户发放返利,2271,2271-6,sit,bs
主数据平台:后台运营系统客户发放返利查询接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url5")
request_body = commonFuc().get_business_data(module, "payload5")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 此函数用于当x为none时,进行空字符串替换
def func(x):
if x is None:
x = ""
return x
else:
return x
# 生成一个随机数字,用于后续随机选择某一条客户发放返利信息
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取客户发放返利列表中某一条返利信息
customer_code = result["data"]["list"][rebate_random]["customerCode"]
telephone = result["data"]["list"][rebate_random]["telephone"]
company_name = result["data"]["list"][rebate_random]["companyName"]
rebate_id = result["data"]["list"][rebate_random]["rebateId"]
rebate_name = result["data"]["list"][rebate_random]["rebateName"]
relevance_name = result["data"]["list"][rebate_random]["relevanceName"]
# 第三步进行条件查询验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url6")
request_body = commonFuc().get_business_data(module, "payload6", customer_code, telephone, company_name,
rebate_id, rebate_name, relevance_name)
"""
场景: 验证客户发放返利列表查询条件是否可以正常使用
用例名称:列表查询条件验证_客户发放返利
输出:{"customerCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取查询结果中返利明细对应的客户编号
result = {"customerCode": result["data"]["list"][0]["customerCode"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict6", customer_code)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_客户范围,2271,2271-27,sit,bs
主数据平台:后台运营系统返利规则商品客户范围查询接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url3")
request_body = commonFuc().get_business_data(module, "payload3")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_id = result["data"]["list"][rebate_random]["rebateid"]
print(rebate_id)
# 第三步获取返利规则对应的客户范围
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url13")
request_body = commonFuc().get_business_data(module, "payload13", rebate_id)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 生成一个随机数字,用于后续随机选择某一条客户信息
customer_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则中客户范围列表中某一条客户信息
customer_name = result["data"]["list"][customer_random]["customername"]
customer_code = result["data"]["list"][customer_random]["customercode"]
# 第四步进行条件查询验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url14")
request_body = commonFuc().get_business_data(module, "payload14", customer_name, customer_code, rebate_id)
print(request_body)
"""
场景: 验证返利规则对应的客户范围列表查询条件是否可以正常使用
用例名称:列表查询条件验证_客户范围
输出:{"customercode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取查询结果对应的客户编号
result = {"customercode": result["data"]["list"][0]["customercode"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict14", customer_code)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
...@@ -41,14 +41,14 @@ def func(x): ...@@ -41,14 +41,14 @@ def func(x):
# 生成一个随机数字,用于后续随机选择某一条返利使用明细 # 生成一个随机数字,用于后续随机选择某一条返利使用明细
rebate_random = random.randint(0, len(result["data"]["list"]) - 1) rebate_random = random.randint(1, len(result["data"]["list"]) - 1)
# 获取返利使用明细列表中某一条明细信息 # 获取返利使用明细列表中某一条明细信息
customer_code = result["data"]["list"][rebate_random]["customerCode"] customer_code = result["data"]["list"][rebate_random]["customerCode"]
customer_name = result["data"]["list"][rebate_random]["customerName"] customer_name = func(result["data"]["list"][rebate_random]["customerName"])
relevance_name = result["data"]["list"][rebate_random]["relevanceName"] relevance_name = result["data"]["list"][rebate_random]["relevanceName"]
transaction_type = result["data"]["list"][rebate_random]["transactionType"] transaction_type = result["data"]["list"][rebate_random]["transactionType"]
rebate_id = result["data"]["list"][rebate_random]["rebateId"] rebate_id = func(result["data"]["list"][rebate_random]["rebateId"])
rebate_name = result["data"]["list"][rebate_random]["rebateName"] rebate_name = func(result["data"]["list"][rebate_random]["rebateName"])
list_order_status = func(result["data"]["list"][rebate_random]["orderStatus"]) list_order_status = func(result["data"]["list"][rebate_random]["orderStatus"])
demand_code = func(result["data"]["list"][rebate_random]["demandCode"]) demand_code = func(result["data"]["list"][rebate_random]["demandCode"])
start_time = result["data"]["list"][rebate_random]["createTimeStr"] start_time = result["data"]["list"][rebate_random]["createTimeStr"]
...@@ -61,7 +61,7 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_code, ...@@ -61,7 +61,7 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_code,
transaction_type, transaction_type,
rebate_id, rebate_name, list_order_status, demand_code, start_time, rebate_id, rebate_name, list_order_status, demand_code, start_time,
end_time) end_time)
# print(request_body)
""" """
场景: 验证返利使用明细列表查询条件是否可以正常使用 场景: 验证返利使用明细列表查询条件是否可以正常使用
用例名称:列表查询条件验证_返利使用明细 用例名称:列表查询条件验证_返利使用明细
...@@ -72,9 +72,17 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_code, ...@@ -72,9 +72,17 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_code,
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content) result = json.loads(result.content)
print(result) print(result)
# 获取查询结果中使用明细对应的客户编号 if result["data"]["list"]:
result = {"customerCode": result["data"]["list"][0]["customerCode"]} # 获取查询结果中使用明细对应的客户编号
# 获取预期结果 result = {"customerCode": result["data"]["list"][0]["customerCode"]}
check_dict = commonFuc().get_business_data(module, "checkDict2", customer_code) # 获取预期结果
# 断言实际结果中是否包含预期结果的内容 check_dict = commonFuc().get_business_data(module, "checkDict2", customer_code)
commonFuc().check_result(check_dict, result) # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 获取查询结果中使用明细对应的客户编号
result = {"list": result["data"]["list"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2_1")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_返利发放列表,2271,2271-39,sit,bs
主数据平台:后台运营系统返利发放明细查询接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import random
import requests
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url33")
request_body = commonFuc().get_business_data(module, "payload33")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数字
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利信息
status = result["data"]["list"][rebate_random]["status"]
rebate_theme = result["data"]["list"][rebate_random]["rebateTheme"]
customer_name = result["data"]["list"][rebate_random]["rebatetripCusList"][0]["customerName"]
customer_code = result["data"]["list"][rebate_random]["rebatetripCusList"][0]["customerCode"]
product_name = result["data"]["list"][rebate_random]["rebatetripProList"][0]["productName"]
product_code = result["data"]["list"][rebate_random]["rebatetripProList"][0]["productCode"]
# 第三步进行返利发放信息查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url34")
request_body = commonFuc().get_business_data(module, "payload34", status, rebate_theme, customer_name, customer_code,
product_name, product_code)
"""
场景: 列表查询条件验证_返利发放列表
用例名称:列表查询条件验证_返利发放列表
输出:{"rebateTheme":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取查询结果中的返利信息
result = {"rebateTheme": result["data"]["list"][0]["rebateTheme"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict34", rebate_theme)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_返利审核,2271,2271-20,sit,bs
主数据平台:后台运营系统返利审核列表查询接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url8")
request_body = commonFuc().get_business_data(module, "payload8")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 此函数用于当x为none时,进行空字符串替换
def func(x):
if x is None:
x = ""
return x
else:
return x
# 生成一个随机数字,用于后续随机选择返利审核记录
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利审核列表中某一条审核记录信息
create_name = result["data"]["list"][rebate_random]["createname"]
audit_status = result["data"]["list"][rebate_random]["auditstatus"]
rebate_name = result["data"]["list"][rebate_random]["rebatename"]
# 第三步进行条件查询验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url9")
request_body = commonFuc().get_business_data(module, "payload9", create_name, audit_status, rebate_name)
"""
场景: 验证返利审核列表查询条件是否可以正常使用
用例名称:列表查询条件验证_返利审核
输出:{"rebatename":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取查询结果中使用明细对应的客户编号
result = {"rebatename": result["data"]["list"][0]["rebatename"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict9", rebate_name)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc可使用商品返利清单获取验证,2271,2271-44,sit,bs
主数据平台:后台运营系统可使用商品返利清单查询接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.db.db import mySql
import requests
import random
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url33")
request_body = commonFuc().get_business_data(module, "payload33")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_trip_td = result["data"]["list"][rebate_random]["rebateTripId"]
# 第三步获取可使用商品返利清单
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35")
request_body = commonFuc().get_business_data(module, "payload35", rebate_trip_td)
"""
场景: 验证可使用商品返利清单查询接口是否可正常使用
用例名称:可使用商品返利清单获取验证
输出:{"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, "checkDict35")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# 获取可使用商品数量
total = result["data"]["total"]
# print(total)
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询返利规则1包含的可使用商品数量
sql = "SELECT t.rebatetripProductId FROM `cmdc-order`.tc_rebatetrip_pro t WHERE rebateTripId = {}".format(rebate_trip_td)
result = {"total": len(mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql))}
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict35_1", total)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc已发放客户清单获取验证,2271,2271-46,sit,bs
主数据平台:后台运营系统可发放客户清单查询接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.db.db import mySql
import requests
import random
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url33")
request_body = commonFuc().get_business_data(module, "payload33")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_trip_td = result["data"]["list"][rebate_random]["rebateTripId"]
# 第三步获取可发放客户清单
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url37")
request_body = commonFuc().get_business_data(module, "payload37", rebate_trip_td)
"""
场景: 验证已发放客户清单查询接口是否可正常使用
用例名称:已发放客户清单获取验证
输出:{"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, "checkDict37")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# 获取对应的已发放客户数量
total = result["data"]["total"]
# print(total)
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询返利规则1对应的已发放客户数量
sql = "SELECT t.rebatetripCusId FROM `cmdc-order`.tc_rebatetrip_cus t WHERE rebateTripId = {}".format(rebate_trip_td)
result = {"total": len(mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql))}
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict37_1", total)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
\ No newline at end of file
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc商品黑名单批量导入_返利规则_商品与产品线不匹配,2271,2271-18,sit,bs
主数据平台:运营后台管理系统商品黑名单批量导入接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import requests
import json
import os
import random
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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_file", cmdc_access_token)
# 获取文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/商品模板.xlsx"
# 第二步获取商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_product")
request_body = commonFuc().get_business_data(module, "payload_product")
# 发送请求
result = requests.post(url, headers=headers, json=request_body)
result = json.loads(result.content)
# 生成随机数
product_random = random.randint(1, len(result["data"]["list"]) - 1)
# 获取商品code
product_code = result["data"]["list"][product_random]["relevanceCode"]
# 将商品信息写入导入模板中
excel = HandleExcel(file_path, "Sheet1")
excel.write_data(row=2, column=1, value=product_code)
# 第四步,进行文件导入操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url19")
request_body = commonFuc().get_business_data(module, "payload20")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 验证当进行商品黑名单批量导入时,商品与产品线不匹配时,是否拦截成功
用例名称:商品黑名单批量导入_返利规则_商品与产品线不匹配
输出:{"success":false}
"""
# 发送请求
result = requests.post(url, files=files, headers=headers, data=request_body)
result = json.loads(result.content)
print(result)
file.close()
result = {"success": result["data"]["errMsg"]["success"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict20")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc商品黑名单批量导入验证_返利规则,2271,2271-17,sit,bs
主数据平台:运营后台管理系统商品黑名单批量导入接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import requests
import json
import os
import random
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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_file", cmdc_access_token)
# 获取文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/商品模板.xlsx"
# 第二步获取商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_product")
request_body = commonFuc().get_business_data(module, "payload_product")
# 发送请求
result = requests.post(url, headers=headers, json=request_body)
result = json.loads(result.content)
# 生成随机数
product_random = random.randint(1, len(result["data"]["list"]) - 1)
# 获取商品code
product_code = result["data"]["list"][product_random]["relevanceCode"]
# 将商品信息写入导入模板中
excel = HandleExcel(file_path, "Sheet1")
excel.write_data(row=2, column=1, value=product_code)
# 第四步,进行文件导入操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url19")
request_body = commonFuc().get_business_data(module, "payload19")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 商品黑名单批量导入验证_返利规则
用例名称:商品黑名单批量导入验证_返利规则
输出:{"success":true}
"""
# 发送请求
result = requests.post(url, files=files, headers=headers, data=request_body)
result = json.loads(result.content)
print(result)
file.close()
result = {"success": result["data"]["errMsg"]["success"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict19")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc审核拒绝验证_返利审核,2271,2271-22,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_rebate"
# 第一步登录后台运营平台获取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, "url8")
request_body = commonFuc().get_business_data(module, "payload8_2")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取待审核数据
rebate_id = result["data"]["list"][0]["rebateid"]
# 审核拒绝状态
audit_status = 103
# 审核节点:一级审核
audit_level = 2
# 第三步进行条件查询验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url10")
request_body = commonFuc().get_business_data(module, "payload10_2", rebate_id, audit_status, audit_level)
"""
场景: 验证返利审核页面审核拒绝功能是否可以正常使用
用例名称:审核拒绝验证_返利审核
输出:{"auditstatus":"%s"}
"""
# 发送请求
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.auditStatus FROM `cmdc-order`.tc_rebate t WHERE rebateId = {}".format(rebate_id)
result = {"auditstatus": mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]}
# 一级审核通过状态变为审核拒绝
audit_status = 103
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict10", audit_status)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc审核权限用户获取验证,2271,2271-23,sit,bs
主数据平台:后台运营审核权限用户查询接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url7")
request_body = commonFuc().get_business_data(module, "payload7")
"""
场景: 审核权限用户获取验证
用例名称:审核权限用户获取验证
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict7")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc审核通过验证_返利审核,2271,2271-21,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_rebate"
# 第一步登录后台运营平台获取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, "url8")
request_body = commonFuc().get_business_data(module, "payload8_1")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取待审核数据
rebate_id = result["data"]["list"][0]["rebateid"]
# 审核通过状态
audit_status = 102
# 审核节点:一级审核
audit_level = 1
# 第三步进行条件查询验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url10")
request_body = commonFuc().get_business_data(module, "payload10_1", rebate_id, audit_status, audit_level)
"""
场景: 验证返利审核页面审核通过功能是否可以正常使用
用例名称:审核通过验证_返利审核
输出:{"auditstatus":"%s"}
"""
# 发送请求
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.auditStatus FROM `cmdc-order`.tc_rebate t WHERE rebateId = {}".format(rebate_id)
result = {"auditstatus": mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]}
# 一级审核通过状态变为二级审核中
audit_status = 104
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict10", audit_status)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc客户发放返利新增验证,2271,2271-33,sit,bs
主数据平台:运营后台管理系统客户发放返利新增接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
from datetime import timedelta, date
import requests
import json
import os
import random
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url28_1")
request_body = commonFuc().get_business_data(module, "payload28_1")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 生成一个随机数字,用于后续随机选择某一条客户发放返利信息
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_id = result["data"]["list"][rebate_random]["rebateid"]
# 第三步获取返利规则详情信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url23")
request_body = commonFuc().get_business_data(module, "payload23", rebate_id)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取规则对应的客户信息
customer_code = result["data"]["customerDataList"][random.randint(0, len(result["data"]["customerDataList"]) - 1)][
"customercode"]
# 生成随机返利金额
amount = random.randint(1, 1000)
# 随机生成日期
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)
# 第四步,进行客户发放返利新增
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url30")
request_body = commonFuc().get_business_data(module, "payload30", rebate_id, amount, customer_code)
"""
场景: 客户发放返利新增验证
用例名称:客户发放返利新增验证
输出:{"success":true,"code":"200"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict30")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc客户发放返利编辑功能验证,2271,2271-31,sit,bs
主数据平台:后台运营系统客户发放返利新增接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url5")
request_body = commonFuc().get_business_data(module, "payload5")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取客户发放返利信息
customer_code = result["data"]["list"][0]["customerCode"]
rebate_id = result["data"]["list"][0]["rebateId"]
amount = random.randint(1, 10000)
# 第三步进行返利编辑
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url30")
request_body = commonFuc().get_business_data(module, "payload30", rebate_id, amount, customer_code)
"""
场景: 客户发放返利编辑功能验证
用例名称:客户发放返利编辑功能验证
输出:{"success":true,"code":"200"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict30")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc客户名单批量导入验证_返利规则,2271,2271-16,sit,bs
主数据平台:运营后台管理系统客户名单批量导入接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import requests
import json
import os
import random
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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_file", cmdc_access_token)
# 获取文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/客户名单模板.xlsx"
# 第二步获取客户信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_customer")
request_body = commonFuc().get_business_data(module, "payload_customer")
# 发送请求
result = requests.post(url, headers=headers, json=request_body)
result = json.loads(result.content)
# 生成随机数
customer_random = random.randint(1, len(result["data"]["list"]) - 1)
# 获取客户code
customer_code = result["data"]["list"][customer_random]["customerCode"]
customer_name = result["data"]["list"][customer_random]["customerName"]
# 将客户信息写入导入模板中
excel = HandleExcel(file_path, "Sheet1")
excel.write_data(row=2, column=1, value=customer_name)
excel.write_data(row=2, column=2, value=customer_code)
# 第四步,进行文件导入操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url18")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 客户名单批量导入验证_返利规则
用例名称:客户名单批量导入验证_返利规则
输出:{"success":true}
"""
# 发送请求
result = requests.post(url, files=files, headers=headers)
result = json.loads(result.content)
print(result)
file.close()
result = {"success": result["data"]["errMsg"]["success"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict18")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc批量导入商品验证_返利发放管理,2271,2271-36,sit,bs
主数据平台:运营后台管理系统返利发放商品批量导入接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import requests
import json
import os
import random
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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_file", cmdc_access_token)
# 获取文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/批量导入商品模板.xlsx"
# 第二步获取产品线商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url15")
request_body = commonFuc().get_business_data(module, "payload15")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数字,用于后续随机选择商品
product_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取产品线商品列表中商品信息
product_name = result["data"]["list"][product_random]["relevanceName"]
product_code = result["data"]["list"][product_random]["relevanceCode"]
# 将商品信息写入导入模板中
excel = HandleExcel(file_path, "Sheet1")
excel.write_data(row=2, column=1, value=product_code)
excel.write_data(row=2, column=2, value=product_name)
# 第四步,进行文件导入操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url41")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 批量导入商品验证_返利发放管理
用例名称:批量导入商品验证_返利发放管理
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, files=files, headers=headers)
result = json.loads(result.content)
# print(result)
file.close()
result = {"productCode": result["data"][0]["productCode"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict41", product_code)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc批量导入客户验证_返利发放管理,2271,2271-37,sit,bs
主数据平台:运营后台管理系统返利发放客户批量导入接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import requests
import json
import os
import random
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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_file", cmdc_access_token)
# 获取文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/批量导入用户模板.xlsx"
# 第二步获取三方用户信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url31")
request_body = commonFuc().get_business_data(module, "payload31")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数字,用于后续随机选择三方用户信息
user_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取三方用户信息
customer_name = result["data"]["list"][user_random]["customerName"]
customer_code = result["data"]["list"][user_random]["customerCode"]
# customer_code = "1017911"
# 生成返利金额
amount = float(random.randint(1, 1000))
# 将客户信息写入导入模板中
excel = HandleExcel(file_path, "Sheet1")
excel.write_data(row=2, column=1, value=customer_code)
excel.write_data(row=2, column=2, value=customer_name)
excel.write_data(row=2, column=3, value=amount)
excel.write_data(row=2, column=4, value="批量导入客户验证")
# 第四步,进行文件导入操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url40")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 批量导入客户验证_返利发放管理
用例名称:批量导入客户验证_返利发放管理
输出:{"customerCode":"%s"}
"""
# 发送请求
result = requests.post(url, files=files, headers=headers)
result = json.loads(result.content)
print(result)
file.close()
if result["success"]:
# 导入成功
result = {"customerCode": result["data"][0]["customerCode"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict40", customer_code)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 客户编码未与此站点首营
result = {"message": result["message"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict40_1")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc批量导入验证_客户发放返利,2271,2271-30,sit,bs
主数据平台:运营后台管理系统客户发放返利批量导入接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
from datetime import timedelta, date
import requests
import json
import os
import random
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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_file", cmdc_access_token)
# 获取文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/返利模板.xlsx"
# 第二步获取返利规则列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url28_1")
request_body = commonFuc().get_business_data(module, "payload28_1")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 生成一个随机数字,用于后续随机选择某一条客户发放返利信息
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_id = result["data"]["list"][rebate_random]["rebateid"]
# 第三步获取返利规则详情信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url23")
request_body = commonFuc().get_business_data(module, "payload23", rebate_id)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取规则对应的客户信息
customer_code = result["data"]["customerDataList"][random.randint(0, len(result["data"]["customerDataList"]) - 1)][
"customercode"]
# 生成随机返利金额
amount = random.randint(1, 1000)
# 随机生成日期
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)
# 将客户信息写入导入模板中
excel = HandleExcel(file_path, "Sheet1")
excel.write_data(row=2, column=1, value=customer_code)
excel.write_data(row=2, column=2, value=rebate_id)
excel.write_data(row=2, column=3, value=amount)
excel.write_data(row=2, column=4, value=start_date.strftime('%Y/%m/%d'))
excel.write_data(row=2, column=5, value=random_date.strftime('%Y/%m/%d'))
excel.write_data(row=2, column=6, value="客户发放返利批量导入验证")
# 第四步,进行文件导入操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url29")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 批量导入验证_客户发放返利
用例名称:批量导入验证_客户发放返利
输出:{"success":true}
"""
# 发送请求
result = requests.post(url, files=files, headers=headers)
result = json.loads(result.content)
print(result)
file.close()
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict29")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
\ No newline at end of file
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询客户对应返利规则验证,2271,2271-32,sit,bs
主数据平台:后台运营系统查询客户对应返利规则接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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, "url28_1")
request_body = commonFuc().get_business_data(module, "payload28_1")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 生成一个随机数字,用于后续随机选择某一条客户发放返利信息
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_id = result["data"]["list"][rebate_random]["rebateid"]
# 第三步获取返利规则详情信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url23")
request_body = commonFuc().get_business_data(module, "payload23", rebate_id)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 获取规则对应的客户信息
customer_code = result["data"]["customerDataList"][random.randint(0, len(result["data"]["customerDataList"]) - 1)][
"customercode"]
# 第四步获取客户对应的返利规则
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url28")
request_body = commonFuc().get_business_data(module, "payload28", customer_code)
"""
场景: 查询客户对应返利规则验证
用例名称:查询客户对应返利规则验证
输出:{"customercode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取结果中返利规则中客户编码
result = {"customercode": result["data"][0]["customercode"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict28", customer_code)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc返利发放新增验证,2271,2271-40,sit,bs
主数据平台:后台运营系统返利发放新增接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.db.db import mySql
import requests
import random
import uuid
import json
module = "cmdc_rebate"
# 第一步登录后台运营平台获取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)
# 生成返利发放规则主题
theme = uuid.uuid4()
# 生成可抵扣下单金额最高比例
use_limit = random.randint(1, 99)
# 第二步进行返利发放规则新增
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url43")
request_body = commonFuc().get_business_data(module, "payload43", theme, use_limit)
"""
场景: 返利发放新增验证
用例名称:返利发放新增验证
输出:{"rebateTheme":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
if result["success"]:
# 获取返利发放明细
rebate_trip_id = result["data"]["rebateTripId"]
rebate_theme = result["data"]["rebateTheme"]
print(rebate_trip_id)
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询返利发放规则主题
sql = "SELECT t.rebateTheme FROM `cmdc-order`.tc_rebatetrip t WHERE rebateTripId = {}".format(rebate_trip_id)
result = {"rebateTheme": mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]}
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict43", rebate_theme)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# 对新增的返利发放规则进行删除操作
sql = "DELETE FROM `cmdc-order`.tc_rebatetrip WHERE rebateTripId = {}".format(rebate_trip_id)
mysql_handle.executeUpdate(host, port, user, pwd, "cmdc-order", sql)
else:
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict43_1")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
\ 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