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

Merge branch 'master' into 'main'

Master|更新商品模块和订单逆向模块用例

See merge request !5
parents ffa18436 8fa1e69c
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_商品列表_库存配置,2293,2293-028,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, "url20")
request_body = commonFuc().get_business_data(module, "payload20")
# 发送请求
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_name = result["data"]["list"][rebate_random]["productName"]
product_code = result["data"]["list"][rebate_random]["productCode"]
# 进行列表查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url21")
request_body = commonFuc().get_business_data(module, "payload21", product_code, product_name)
"""
场景: 列表查询条件验证_商品列表_库存配置
用例名称:列表查询条件验证_商品列表_库存配置
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取查询结果中商品信息
result = {"productCode": result["data"]["list"][0]["productCode"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict21", product_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_商品属性列表,2293,2293-002,sit,bs
主数据平台:后台运营系统商品属性列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import datetime
import random
import json
module = "cmdc_product"
# 第一步登录后台运营平台获取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, "url1")
request_body = commonFuc().get_business_data(module, "payload1")
# 发送请求
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)
# 获取商品属性信息
product_code = result["data"]["list"][rebate_random]["productCode"]
product_name = func(result["data"]["list"][rebate_random]["productName"])
specifications = result["data"]["list"][rebate_random]["specifications"]
material_code = result["data"]["list"][rebate_random]["materialCode"]
manufacturer = func(result["data"]["list"][rebate_random]["manufacturer"])
property_name = func(result["data"]["list"][rebate_random]["propertyName"])
property_note = func(result["data"]["list"][rebate_random]["propertyNote"])
property_val = func(result["data"]["list"][rebate_random]["propertyVal"])
create_time_start = result["data"]["list"][rebate_random]["createTime"]
update_time_start = result["data"]["list"][rebate_random]["updateTime"]
# 获取当前时间作为创建时间和最近修改时间截止时间
end_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# 第三步进行条件查询验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body = commonFuc().get_business_data(module, "payload2", product_code, product_name, specifications,
material_code,
manufacturer, property_name, property_note, property_val, create_time_start,
end_time, end_time, update_time_start)
# print(request_body)
"""
场景: 验证商品明细列表查询条件是否可以正常使用
用例名称:列表查询条件验证_商品属性列表
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取查询结果中商品code
result = {"productCode": result["data"]["list"][0]["productCode"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2", product_code)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- 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)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_库存配置列表,2293,2293-021,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, "url13")
request_body = commonFuc().get_business_data(module, "payload13")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数字,用于后续随机选择某一条商品属性信息
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取库存配置信息
rule_name = result["data"]["list"][rebate_random]["ruleName"]
# 获取库存配置列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url14")
request_body = commonFuc().get_business_data(module, "payload14", rule_name)
"""
场景: 验证库存配置列表查询条件正确性
用例名称:列表查询条件验证_库存配置列表
输出:{"ruleName":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取查询结果中库存配置名称
result = {"ruleName": result["data"]["list"][0]["ruleName"]}
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict14", rule_name)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc发货时间规则停用功能验证,2293,2293-037,sit,bs
主数据平台:运营后台管理系统发货时间规则停用接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
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)
# 获取发货时间规则id
delivery_time_id = result["data"]["list"][0]["deliveryTimeId"]
# 进行发货时间规则停用操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url37")
request_body = commonFuc().get_business_data(module, "payload37", delivery_time_id)
"""
场景: 发货时间规则停用功能验证
用例名称:发货时间规则停用功能验证
输出:{"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")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc发货时间规则启用功能验证,2293,2293-038,sit,bs
主数据平台:运营后台管理系统发货时间规则启用接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
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)
# 获取发货时间规则id
delivery_time_id = result["data"]["list"][0]["deliveryTimeId"]
# 进行发货时间规则启用操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url38")
request_body = commonFuc().get_business_data(module, "payload38", delivery_time_id)
"""
场景: 发货时间规则启用功能验证
用例名称:发货时间规则启用功能验证
输出:{"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, "checkDict38")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc商品价格明细导出验证,2293,2293-057,sit,bs
涉及到接口:多采商城库商品价格明细导出接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import requests
import random
import json
import os
module = "cmdc_product"
# 第一步登录多采商城获取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)
# 第二步获取雅培折扣价格信息列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url49")
request_body = commonFuc().get_business_data(module, "payload49")
# 发送请求
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_code = result["data"]["list"][product_random]["productCode"]
# 第三步商品价格明细导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url53")
request_body = commonFuc().get_business_data(module, "payload53", product_code)
# print(request_body)
"""
场景: 商品价格明细导出验证
用例名称:商品价格明细导出验证
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# result = json.loads(result.content)
# print(result)
# 获取文件
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"
# 获取到导出文件存入cmdc_files文件中
with open(file_path, 'wb') as f:
f.write(result.content)
# 获取文件中商品编码
excel = HandleExcel(file_path, "Sheet1")
result = {"productCode": excel.read_data()[0].get("商品编码")}
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict53", product_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc商品属性修改功能验证,2293,2293-005,sit,bs
主数据平台:后台运营系统商品属性修改接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_product"
# 第一步登录后台运营平台获取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, "url1")
request_body = commonFuc().get_business_data(module, "payload1")
# 发送请求
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)
# 获取商品属性信息
product_id = result["data"]["list"][rebate_random]["productId"]
product_name = func(result["data"]["list"][rebate_random]["productName"])
property_id = func(result["data"]["list"][rebate_random]["propertyId"])
property_name = func(result["data"]["list"][rebate_random]["propertyName"])
property_note = func(result["data"]["list"][rebate_random]["propertyNote"])
property_val = func(result["data"]["list"][rebate_random]["propertyVal"])
# 第三步对商品属性进行修改功能验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url5")
request_body = commonFuc().get_business_data(module, "payload5", product_id, property_id, property_name, property_note,
property_val, property_name)
# print(request_body)
"""
场景: 商品属性修改功能验证
用例名称:商品属性修改功能验证
输出:{"data":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取查询结果中data信息
result = {"data": result["data"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict5", property_id)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc商品属性批量新增功能验证,2293,2293-009,sit,bs
主数据平台:后台运营系统商品属性批量新增接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import requests
import random
import json
import os
module = "cmdc_product"
# 第一步登录后台运营平台获取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, "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)
# 获取商品信息
product_code = result["data"]["list"][rebate_random]["productCode"]
product_name = result["data"]["list"][rebate_random]["productName"]
# 将商品信息写入文件中
excel = HandleExcel(file_path, "Sheet1")
excel.write_data(row=2, column=1, value=product_name)
excel.write_data(row=2, column=2, value=product_code)
excel.write_data(row=2, column=3, value=rebate_random)
excel.write_data(row=2, column=4, value=rebate_random)
excel.write_data(row=2, column=5, value=rebate_random)
# 第三步进行商品属性批量新增
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url8")
# print(url)
request_body = {"importSign": "productProperties", "area": ""}
# print(request_body)
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 商品属性批量新增功能验证
用例名称:商品属性批量新增功能验证
输出:{"success":true,"code":"200","message":null,"data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, files=files, headers=headers, params=request_body)
result = json.loads(result.content)
file.close()
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict8")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc商品附件列表获取,2293,2293-011,sit,bs
主数据平台:运营后台管理系统商品附件列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
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")
"""
场景: 验证商品附件列表接口连通性
用例名称:商品附件列表获取
输出:{"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, "checkDict11")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc商品限购明细导出验证,2293,2293-045,sit,bs
主数据平台:运营后台管理系统商品限购明细导出接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import requests
import random
import json
import os
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, "url41")
request_body = commonFuc().get_business_data(module, "payload41")
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
product_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取商品限购信息
product_code = result["data"]["list"][product_random]["productCode"]
# 进行商品限购明细导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url45")
request_body = commonFuc().get_business_data(module, "payload45", product_code)
"""
场景: 商品限购明细导出验证
用例名称:商品限购明细导出验证
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# result = json.loads(result.content)
# print(result)
# 获取文件
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"
# 获取到导出文件存入cmdc_files文件中
with open(file_path, 'wb') as f:
f.write(result.content)
# 获取文件中商品信息
excel = HandleExcel(file_path, "Sheet1")
result = {"productCode": excel.read_data()[0].get("商品编码")}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict45", product_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc导入日志获取,2293,2293-003,sit,bs
主数据平台:运营后台管理系统导入日志获取接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
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, "url10")
request_body = commonFuc().get_business_data(module, "payload10")
"""
场景: 验证导入日志获取接口连通性
用例名称:导入日志获取
输出:{"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, "checkDict10")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc将产品线信息同步JDE,2293,2293-079,sit,bs
主数据平台:运营后台管理系统将产品线信息同步JDE接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
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)
# 产品线信息同步JDE
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url73")
request_body = commonFuc().get_business_data(module, "payload73")
"""
场景: 验证产品线信息同步JDE接口
用例名称:将产品线信息同步JDE
输出:{"success":true,"code":"200","message":"正在同步中","data":null,"freshToken":null}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict73")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc库存规则配置列表获取,2293,2293-020,sit,bs
主数据平台:运营后台管理系统库存规则配置列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
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, "url13")
request_body = commonFuc().get_business_data(module, "payload13")
"""
场景: 库存规则配置列表获取
用例名称:库存规则配置列表获取
输出:{"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, "checkDict13")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc库存配置导出验证,2293,2293-032,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
module = "cmdc_product"
# 第一步登录多采商城获取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)
# 库存配置id
rule_id = "7"
# 第二步获取库存配置详情
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url25")
request_body = commonFuc().get_business_data(module, "payload25", rule_id)
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# 获取库存配置信息
product_line_code = result["data"]["stockRuleProductLineReqVos"][0]["productLineCode"]
# 第三步库存配置导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url26")
request_body = commonFuc().get_business_data(module, "payload26", rule_id)
# print(request_body)
"""
场景: 库存配置导出验证
用例名称:库存配置导出验证
输出:{"productLineCode":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# result = json.loads(result.content)
# print(result)
# 获取文件
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"
# 获取到导出文件存入cmdc_files文件中
with open(file_path, 'wb') as f:
f.write(result.content)
# 获取文件中订单编号
excel = HandleExcel(file_path, "产品线展示库存")
result = {"productLineCode": excel.read_data()[0].get("产品线编码")}
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict26", product_line_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc批量上传商品限购规则日志获取,2293,2293-044,sit,bs
主数据平台:运营后台管理系统批量上传商品限购规则日志接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
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, "url44")
request_body = commonFuc().get_business_data(module, "payload44")
"""
场景: 批量上传商品限购规则日志获取
用例名称:批量上传商品限购规则日志获取
输出:{"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, "checkDict44")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc商品属性明细导出验证,2293,2293-008,sit,bs
涉及到接口:后台运营系统商品属性明细导出接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import requests
import random
import json
import os
module = "cmdc_product"
# 第一步登录后台运营平台获取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)
# 第二步获取商品属性列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body = commonFuc().get_business_data(module, "payload1")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
random_demand = random.randint(0, len(result["data"]["list"]) - 1)
# 获取商品属性信息
product_code = result["data"]["list"][random_demand]["productCode"]
# 第三步进行明细导出操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url9")
request_body = commonFuc().get_business_data(module, "payload9", product_code)
# print(request_body)
"""
场景: 商品属性明细导出验证
用例名称:商品属性明细导出验证
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# result = json.loads(result.content)
# print(result)
# 获取文件
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"
# 获取到导出文件存入cmdc_files文件中
with open(file_path, 'wb') as f:
f.write(result.content)
# 获取导出明细文件中商品code
excel = HandleExcel(file_path, "商品属性")
result = {"productCode": excel.read_data()[0].get("商品编码")}
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict9", product_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
import random
"""
case_tag:cmdc_api,cmdc查看发货时间详情,2293,2293-036,sit,bs
主数据平台:运营后台管理系统发货时间详情接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
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)
# 获取发货时间id
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)
"""
场景: 查看发货时间详情
用例名称:查看发货时间详情
输出:{"id":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取发货时间详情中id
result = {"id": result["data"]["deliveryTimeId"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict36", delivery_time_id)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查看雅培商品折扣规则批量导入日志,2293,2293-061,sit,bs
主数据平台:运营后台管理系统查看雅培商品折扣规则批量导入日志接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
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, "url52")
request_body = commonFuc().get_business_data(module, "payload52")
"""
场景: 查看雅培商品折扣规则批量导入日志
用例名称:查看雅培商品折扣规则批量导入日志
输出:{"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, "checkDict52")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询条件验证_下单数量列表,2293,2293-064,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, "url57")
request_body = commonFuc().get_business_data(module, "payload57")
# 发送请求
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]["productName"]
product_code = result["data"]["list"][product_random]["productCode"]
specifications = result["data"]["list"][product_random]["specifications"]
status = result["data"]["list"][product_random]["status"]
# 进行查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url58")
request_body = commonFuc().get_business_data(module, "payload58", product_name, product_code, specifications, status)
"""
场景: 查询条件验证_下单数量列表
用例名称:查询条件验证_下单数量列表
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取查询结果中商品信息
result = {"productCode": result["data"]["list"][0]["productCode"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict58", product_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
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