Commit 5271a37a authored by 周念东's avatar 周念东
Browse files

20240617

parents ced008e1 c3acdd56
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc通过批号获取范围上报数据_前台_批次号无效,00,00-81,sit,be
主数据平台:后台运营系统通过批号获取范围上报数据接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import requests
import json
module = "cmdc_special_version"
# 第一步登录多采商城获取token
username = commonFuc().get_business_data(module, "username_testtest")
password = commonFuc().get_business_data(module, "password_testtest")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步通过批号获取范围上报数据
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url81")
request_body = commonFuc().get_business_data(module, "payload81")
"""
场景: 通过批号获取范围上报数据_前台_批次号无效
用例名称:通过批号获取范围上报数据_前台_批次号无效
输出:{"success":false,"code":"ERROR","message":"生产批号:3245234654363656 不存在或已上报"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 将接口响应时间添加至result
result = json.loads(result.content)
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict81")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc通过批次号获取上报数据验证,00,00-65,sit,be
主数据平台:后台运营系统通过批次号获取上报数据验证接口
"""
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_version"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username_admin2")
password = commonFuc().get_business_data(module, "password_admin2")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db_be")
# 在数据库中已存在且未被上报的生产批号信息
sql = "SELECT t.batchNumber,t.customerCode FROM `cmdc-order`.tc_report_batch t " \
"WHERE deleteSign = 0 and batchNumber in " \
"(SELECT t1.batchNumber FROM `cmdc-order`.tc_report t1 where reportStatus = 101)"
batchNumber = mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]
customerCode = mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][1]
# 第二步通过批次号获取上报数据验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url65")
request_body = commonFuc().get_business_data(module, "payload65", batchNumber, customerCode)
"""
场景: 通过批次号获取上报数据验证
用例名称:通过批次号获取上报数据验证
输出:{"batchNumber":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取上报数据
result = json.loads(result.content)
# print(result)
result = {"batchNumber": result["data"]["reportList"][0]["batchNumber"]}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict65", batchNumber)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc集配供应商代客下单验证,00,00-1,sit,be
主数据平台:后台运营系统代客下单接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_special_version"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username_do_be")
password = commonFuc().get_business_data(module, "password_do_be")
# 获取登录后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")
"""
场景: 集配供应商代客下单验证
用例名称:集配供应商代客下单验证
输出:{"success":true,"code":"200","message":"ok"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 将接口响应时间添加至result
result = json.loads(result.content)
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc集配客户为空_集配模板新增,00,00-15,sit,be
主数据平台:后台运营系统获取集配模板列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_special_version"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username_admin")
password = commonFuc().get_business_data(module, "password_admin")
# 获取登录后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, "url15")
request_body = commonFuc().get_business_data(module, "payload15")
"""
场景: 集配客户为空_集配模板新增
用例名称:集配客户为空_集配模板新增
输出:{"success":false,"code":"ERROR","message":"保存失败","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 将接口响应时间添加至result
result = json.loads(result.content)
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict15")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc上传图片附件接口验证,2294,2294-3,sit,bs
主数据平台:多采商城上传图片附件接口接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import requests
import json
import os
module = "cmdc_trade"
# 获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", 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/test_file.jpg"
# 进行图片附件上传操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 上传图片附件接口验证
用例名称:上传图片附件接口验证
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
result = requests.post(url, files=files, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
result["api_time"] = api_time
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# 文件关闭
file.close()
\ No newline at end of file
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc单据信息导出验证_欠货列表,2294,2294-10,sit,bs
主数据平台:多采商城欠货列表单据信息导出接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
from common.handle_excel import HandleExcel
import random
import requests
import json
import os
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取订单欠货列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url6")
request_body = commonFuc().get_business_data(module, "payload6")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
order_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取订单欠货信息
demand_code = result["data"]["list"][order_random]["demandCode"]
# 第三步进行单据信息导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url10")
request_body = commonFuc().get_business_data(module, "payload10", demand_code)
"""
场景: 单据信息导出验证_欠货列表
用例名称:单据信息导出验证_欠货列表
输出:{"demandCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 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 = {"demandCode": excel.read_data()[0].get("订单编号")}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict10", demand_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc发货单据导出验证,2294,2294-18,sit,bs
主数据平台:多采商城获取发货单据导出接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
from common.handle_excel import HandleExcel
import requests
import random
import json
import os
module = "cmdc_trade"
# 第一步登录多采商城获取token
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username3")
password = commonFuc().get_business_data(module, "password3")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取发货单物流信息列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url11")
request_body = commonFuc().get_business_data(module, "payload11")
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
jde_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取发货单信息
demand_code = result["data"]["list"][jde_random]["demandCode"]
# 第三步发货单据导出操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url19")
request_body = commonFuc().get_business_data(module, "payload19", demand_code)
# print(request_body)
"""
场景: 发货单据导出验证
用例名称:发货单据导出验证
输出:{"demandCode":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取文件
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")
# print(excel.read_data())
result = {"demandCode": excel.read_data()[0].get("子需求单编号")}
result["api_time"] = api_time
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict19", demand_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc发货单据导出验证_发货单管理,2294,2294-30,sit,bs
主数据平台:后台运营平台发货单据导出接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.handle_excel import HandleExcel
import random
import requests
import json
import os
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username4")
password = commonFuc().get_business_data(module, "password4")
# 获取登录后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, "url25")
request_body = commonFuc().get_business_data(module, "payload25")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 生成随机数
out_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取发货单信息
demand_code = result["data"]["list"][out_random]["demandCode"]
# 第三步发货单据导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url30")
request_body = commonFuc().get_business_data(module, "payload30", demand_code)
"""
场景: 发货单据导出验证_发货单管理
用例名称:发货单据导出验证_发货单管理
输出:{"demandCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取文件
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)
# 获取文件中demandCode
excel = HandleExcel(file_path, "工作表1")
# print(excel.read_data())
result = {"demandCode": excel.read_data()[0].get("子需求单编号")}
# print(result)
result["api_time"] = api_time
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict30", demand_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc发货同步_发货单管理,2294,2294-32,sit,bs
主数据平台:后台运营系统发货同步接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_trade"
# 第一步登录后台运营系统获取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, "url31")
request_body = commonFuc().get_business_data(module, "payload31")
# print(request_body)
"""
场景: 验证发货同步接口连通性
用例名称:发货同步_发货单管理
输出:{"success":true,"code":"200","message":null,"data":null,"freshToken":null}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
# 将获取到接口响应时间添加至result中
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict31")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc发货商品清单查询条件验证_发货详情,2294,2294-29,sit,bs
主数据平台:后台运营系统获取发货单详情接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_trade"
# 第一步登录后台运营系统获取token信息
username = commonFuc().get_business_data(module, "username4")
password = commonFuc().get_business_data(module, "password4")
# 获取登录后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, "url25")
request_body = commonFuc().get_business_data(module, "payload25")
# 发送请求
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
# 生成随机数
out_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取发货单信息
SDDOCO = func(result["data"]["list"][out_random]["SDDOCO"])
demandCode = result["data"]["list"][out_random]["demandCode"]
sddcto = result["data"]["list"][out_random]["sddcto"]
# 第三步获取发货单详情
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url26")
request_body = commonFuc().get_business_data(module, "payload26", demandCode, SDDOCO, sddcto)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取随机数
product_random = random.randint(0, len(result["data"]) - 1)
# 获取商品信息
manufacturer = func(result["data"][product_random]["manufacturer"])
materialCode = func(result["data"][product_random]["materialCode"])
productCode = func(result["data"][product_random]["productCode"])
productName = func(result["data"][product_random]["productName"])
optionStr = func(result["data"][product_random]["optionStr"])
# 第四步进行条件查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url28")
request_body = commonFuc().get_business_data(module, "payload28", manufacturer, materialCode, productCode, productName,
optionStr,
demandCode, SDDOCO, sddcto)
# print(request_body)
"""
场景: 发货商品清单查询条件验证_发货详情
用例名称:发货商品清单查询条件验证_发货详情
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
# 获取productCode
result = {"productCode": result["data"][0]["productCode"]}
result["api_time"] = api_time
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict28", productCode)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc必传字段校验_获取发货单号,2294,2294-17,sit,bs
主数据平台:多采商城获取发货单号接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import requests
import json
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username3")
password = commonFuc().get_business_data(module, "password3")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取发货单对应的发货单号
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url17")
request_body = commonFuc().get_business_data(module, "payload17")
"""
场景: 验证获取发货单号接口字段必填性校验
用例名称:必传字段校验_获取发货单号
输出:{"success":false,"code":"500","message":"内部系统错误","data":null,"freshToken":null}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# 将获取到的响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict17")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc必传字段校验_获取物流详情,2294,2294-14,sit,bs
主数据平台:多采商城获取物流详情接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import requests
import json
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username3")
password = commonFuc().get_business_data(module, "password3")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取物流详情
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url14")
request_body = commonFuc().get_business_data(module, "payload14")
"""
场景: 必传字段校验_获取物流详情
用例名称:必传字段校验_获取物流详情
输出:{"success":false,"code":"ERROR","message":"单号必传","data":null,"freshToken":null}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# 将获取到的响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict14")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询条件验证_发票清单列表,2294,2294-37,sit,be
主数据平台:多采商城获取发票清单列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import random
import requests
import datetime
import json
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username_be")
password = commonFuc().get_business_data(module, "password_be")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取发票清单列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35")
request_body = commonFuc().get_business_data(module, "payload35")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 生成随机数
invoice_random = random.randint(2, len(result["data"]["list"]) - 1)
# 获取发票信息
# print(invoice_random)
invoice_no = result["data"]["list"][invoice_random]["invoiceNo"]
invoice_time_begin = result["data"]["list"][invoice_random]["invoiceTime"].replace("/", "-") + " 00:00:00"
invoice_time_end = datetime.datetime.now().strftime("%Y-%m-%d 23:59:59")
company_ode = (result["data"]["list"][invoice_random]["companyCode"] if result["data"]["list"][invoice_random][
"companyCode"] else "")
demand_parent_code = (
result["data"]["list"][invoice_random]["demandParentCode"] if result["data"]["list"][invoice_random][
"demandParentCode"] else "")
# 第三步进行查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url36")
request_body = commonFuc().get_business_data(module, "payload36", invoice_no, invoice_time_begin, invoice_time_end,
company_ode, demand_parent_code)
# print(request_body)
"""
场景: 查询条件验证_发票清单列表
用例名称:查询条件验证_发票清单列表
输出:{"invoiceNo":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取查询结果中invoiceNo
result = json.loads(result.content)
# print(result)
result = {"invoiceNo": result["data"]["list"][0]["invoiceNo"]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict36", invoice_no)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询条件验证_发货单列表,2294,2294-27,sit,bs
主数据平台:后台运营系统获取发货单列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_trade"
# 第一步登录后台运营系统获取token信息
username = commonFuc().get_business_data(module, "username4")
password = commonFuc().get_business_data(module, "password4")
# 获取登录后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, "url25")
request_body = commonFuc().get_business_data(module, "payload25")
# 发送请求
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
# 生成随机数
out_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取发货单信息
SDDOCO = func(result["data"]["list"][out_random]["SDDOCO"])
customerCode = func(result["data"]["list"][out_random]["customerCode"])
customerName = func(result["data"]["list"][out_random]["customerName"])
demandCode = func(result["data"]["list"][out_random]["demandCode"])
productCode = func(result["data"]["list"][out_random]["productCode"])
optionStr = func(result["data"]["list"][out_random]["optionStr"])
materialCode = func(result["data"]["list"][out_random]["materialCode"])
demandParentCode = func(result["data"]["list"][out_random]["demandParentCode"])
invoiceNo = func(result["data"]["list"][out_random]["invoiceNo"])
productLineName = func(result["data"]["list"][out_random]["productLineName"])
sddcto = func(result["data"]["list"][out_random]["sddcto"])
distributionType = func(result["data"]["list"][out_random]["distributionType"])
demandSubCode = func(result["data"]["list"][out_random]["demandSubCode"])
# 第三步进行条件查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url27")
request_body = commonFuc().get_business_data(module, "payload27", demandCode, demandParentCode)
# print(request_body)
"""
场景: 查询条件验证_发货单列表
用例名称:查询条件验证_发货单列表
输出:{"demandCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
print(result)
# 获取demandCode
result = {"demandCode": result["data"]["list"][0]["demandCode"]}
result["api_time"] = api_time
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict27", demandCode)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询条件验证_发货单物流信息列表,2294,2294-12,sit,bs
主数据平台:多采商城获取发货单物流信息列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import datetime
import random
import requests
import json
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username3")
password = commonFuc().get_business_data(module, "password3")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取发货单物流信息列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url11")
request_body = commonFuc().get_business_data(module, "payload11")
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
jde_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取发货单信息
seller_company_code = result["data"]["list"][jde_random]["sellerCompanyCode"]
demand_parent_code = result["data"]["list"][jde_random]["demandParentCode"]
demand_code = result["data"]["list"][jde_random]["demandCode"]
sd_random = random.randint(0, len(result["data"]["list"][jde_random]["SDDOCOList"]) - 1)
sddoco_1 = result["data"]["list"][jde_random]["SDDOCOList"][sd_random][:8]
start_time = result["data"]["list"][jde_random]["createTime"]
end_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# 第三步获取发货单详情信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url13")
request_body = commonFuc().get_business_data(module, "payload13", demand_parent_code)
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# 获取商品信息
product_code = result["data"]["detail"][0]["list"][0]["productCode"]
option_str = result["data"]["detail"][0]["list"][0]["optionStr"]
# 第四步进行查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url12")
request_body = commonFuc().get_business_data(module, "payload12", demand_parent_code, product_code, end_time,
start_time, end_time, start_time,
demand_code, sddoco_1, option_str)
"""
场景: 查询条件验证_发货单物流信息列表
用例名称:查询条件验证_发货单物流信息列表
输出:{"demandParentCode":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
# 获取查询结果中demandParentCode
result = {"demandParentCode": result["data"]["list"][0]["demandParentCode"]}
# 将获取到的响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict12", demand_parent_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询条件验证_欠货列表,2294,2294-7,sit,bs
主数据平台:多采商城获获取订单欠货列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import random
import requests
import datetime
import json
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取订单欠货列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url6")
request_body = commonFuc().get_business_data(module, "payload6")
# 发送请求
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
# 生成随机数
order_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取订单欠货信息
seller_companyCode = result["data"]["list"][order_random]["sellerCompanyCode"]
demand_code = result["data"]["list"][order_random]["demandCode"]
manufacturer = result["data"]["list"][order_random]["productList"][0]["manufacturer"]
material_code = func(result["data"]["list"][order_random]["productList"][0]["materialCode"])
product_code = result["data"]["list"][order_random]["productList"][0]["productCode"]
payment_type = result["data"]["list"][order_random]["productList"][0]["paymentType"]
create_time = str(result["data"]["list"][order_random]["createTime"][:10] + " 00:00:00")
end_time = str(datetime.datetime.now().strftime('%Y-%m-%d') + " 00:00:00")
# 第三步进行查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url7")
request_body = commonFuc().get_business_data(module, "payload7", seller_companyCode, demand_code, create_time, end_time,
manufacturer, material_code, product_code, payment_type)
"""
场景: 查询条件验证_欠货列表
用例名称:查询条件验证_欠货列表
输出:{"demandCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
# 获取查询结果中订单编号
result = {"demandCode": result["data"]["list"][0]["demandCode"]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict7", demand_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询条件验证_欠货商品行信息,2294,2294-9,sit,bs
主数据平台:多采商城获取欠货商品行信息接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import random
import requests
import json
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取订单欠货列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url6")
request_body = commonFuc().get_business_data(module, "payload6")
# 发送请求
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
# 生成随机数
order_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取订单欠货信息
demand_code = result["data"]["list"][order_random]["demandCode"]
material_code = func(result["data"]["list"][order_random]["productList"][0]["materialCode"])
product_code = result["data"]["list"][order_random]["productList"][0]["productCode"]
# 第三步商品行信息查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url9")
request_body = commonFuc().get_business_data(module, "payload9", demand_code, material_code, product_code)
"""
场景: 查询条件验证_欠货商品行信息
用例名称:查询条件验证_欠货商品行信息
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
# 获取商品行信息中商品信息
result = {"productCode": result["data"][0]["productCode"]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict9", product_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询条件验证_退货单管理,2294,2294-24,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_trade"
# 第一步登录后台运营系统获取toen信息
username = commonFuc().get_business_data(module, "username4")
password = commonFuc().get_business_data(module, "password4")
# 获取登录后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, "url22")
request_body = commonFuc().get_business_data(module, "payload22")
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
code_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取退货单信息
jde_refund_code = result["data"]["list"][code_random]["jdeRefundCode"]
customer_name = result["data"]["list"][code_random]["customerName"]
manufacturer = result["data"]["list"][code_random]["manufacturer"]
material_code = result["data"]["list"][code_random]["materialCode"]
demand_parent_code = result["data"]["list"][code_random]["demandParentCode"]
start_time = result["data"]["list"][code_random]["submitTime"]
end_time = datetime.datetime.now().strftime("%Y-%m-%d")
# 第三步获取退货单详情
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url23")
request_body = commonFuc().get_business_data(module, "payload23", jde_refund_code,
customer_name, manufacturer, material_code, demand_parent_code, start_time,
end_time)
"""
场景: 查询条件验证_退货单管理
用例名称:查询条件验证_退货单管理
输出:{"jdeRefundCode":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取详情页中的jdeRefundCode
result = json.loads(result.content)
result = {"jdeRefundCode": result["data"]["list"][0]["jdeRefundCode"]}
# 将接口响应时间添加到result
result["api_time"] = api_time
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict23", jde_refund_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询条件验证_退货记录列表,2294,2294-34,sit,be
主数据平台:多采商城获取退货记录列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import random
import requests
import datetime
import json
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username_be")
password = commonFuc().get_business_data(module, "password_be")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取退货记录列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url32")
request_body = commonFuc().get_business_data(module, "payload32")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
refund_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取退货记录信息
refund_code = result["data"]["list"][refund_random]["refundCode"]
customer_name = result["data"]["list"][refund_random]["customerName"]
return_type = result["data"]["list"][refund_random]["returnType"]
start_time = result["data"]["list"][refund_random]["refundDate"][:10] + " 00:00:00"
end_time = datetime.datetime.now().strftime('%Y-%m-%d') + " 23:59:59"
seller_company_code = result["data"]["list"][refund_random]["sellerCompanyCode"]
# 第三步进行查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url33")
request_body = commonFuc().get_business_data(module, "payload33", refund_code, customer_name, return_type, start_time,
end_time, seller_company_code)
# print(request_body)
"""
场景: 查询条件验证_退货记录列表
用例名称:查询条件验证_退货记录列表
输出:{"refundCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取退货编号
result = json.loads(result.content)
# print(result)
result = {"refundCode": result["data"]["list"][0]["refundCode"]}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict33", refund_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc查询物流信息_发票清单列表,2294,2294-38,sit,be
主数据平台:多采商城获取物流信息接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import random
import requests
import datetime
import json
module = "cmdc_trade"
# 第一步获取登录多采商城所需账号密码
username = commonFuc().get_business_data(module, "username_be")
password = commonFuc().get_business_data(module, "password_be")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 第二步获取发票清单列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35")
request_body = commonFuc().get_business_data(module, "payload35")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
invoice_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取发票信息
invoice_no = result["data"]["list"][invoice_random]["invoiceNo"]
# 第三步获取物流信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url37")
request_body = commonFuc().get_business_data(module, "payload37", invoice_no)
"""
场景: 验证是否可获取到对应的物流信息
用例名称:查询物流信息_发票清单列表
输出:{"success":true,"code":"200","message":"未查询到数据","data":null,"freshToken":null}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# 将接口响应时间添加至result
result["api_time"] = api_time
if result["data"]:
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict37_1")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict37")
# 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