Commit 2b6d8c1c authored by 李光宇's avatar 李光宇
Browse files

Merge branch 'master' into 'main'

Master|代码更新归档

See merge request !6
parents e7e2bda7 58586362
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc通过Excel添加无效商品_代客下单,2295,2295-49,sit,bs
主数据平台:后台运营系统查询采购单详情信息接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_order_list"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password2")
# 获取登录后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)
# 生成随机数
customer_random = random.randint(0, len(result["data"]["list"]) - 1)
# 生成无效的商品code
product_code = random.randint(0, 1000)
# 获取客户信息
user_no = result["data"]["list"][customer_random]["userNo"]
# 第三步通过Excel添加商品
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url48")
request_body = commonFuc().get_business_data(module, "payload48", product_code, user_no)
"""
场景: 通过Excel添加无效商品_代客下单
用例名称:通过Excel添加无效商品_代客下单
输出:{"success":true,"code":"200","message":"OK","data":{"status":0,"countSuccess":0,"countFail":1,"message":"第1行,该商品不存在!\n","data":[],"maps":[]},"freshToken":null}
"""
# 发送请求
result = requests.post(url, json=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, "checkDict48")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc通过需求单号获取审核后商品清单,2295,2295-96,sit,bs
主数据平台:后台运营系统通过需求单号获取审核后商品清单接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.db.db import mySql
import random
import requests
import json
module = "cmdc_order_list"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password2")
# 获取登录后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, "url_list")
request_body = commonFuc().get_business_data(module, "payload_list")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
demand_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取需求单信息
demandCode = result["data"]["list"][demand_random]["demandCode"]
# 第三步获取需求单审核后商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url96")
request_body = commonFuc().get_business_data(module, "payload96", demandCode)
"""
场景: 通过需求单号获取审核后商品清单
用例名称:通过需求单号获取审核后商品清单
输出:{"total":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取审核后商品信息
result = json.loads(result.content)
result = {"total": result["data"]["total"]}
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 查询数据库中审核后商品数量
sql = "SELECT count(t.demandSkuId) FROM `cmdc-order`.tc_demand_sku t WHERE demandCode = {}".format(demandCode)
total = mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict96", total)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc配货单导出_jde配货列表,2295,2295-3,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_order_list"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password2")
# 获取登录后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, "url2")
request_body = commonFuc().get_business_data(module, "payload2")
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
dis_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取配货单信息
code = result["data"]["list"][dis_random]["demandCodeStr"]
# 第三步进行配货单导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3")
request_body = commonFuc().get_business_data(module, "payload3", code)
"""
场景: 配货单导出_jde配货列表
用例名称:配货单导出_jde配货列表
输出:{"code":"%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/jde配货单当前列表.xlsx"
# 获取到导出文件存入cmdc_files文件中
with open(file_path, 'wb') as f:
f.write(result.content)
# 获取导出文件中子需求单
excel = HandleExcel(file_path, "Sheet1")
# print(excel.read_data())
result = {"code": excel.read_data()[0].get("子需求单")}
# 将接口响应时间添加至结果中
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3", code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc采购单导出验证_采购单列表,2295,2295-8,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_order_list"
# 第一步登录后台运营系统获取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, "url6")
request_body = commonFuc().get_business_data(module, "payload6")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# 生成随机数
pur_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取采购单信息
bill_no = result["data"]["list"][pur_random]["billNo"]
# 第三步进行采购导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url8")
request_body = commonFuc().get_business_data(module, "payload8", bill_no)
# print(request_body)
"""
场景: 采购单导出验证_采购单列表
用例名称:采购单导出验证_采购单列表
输出:{"billNo":"%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)
# 获取导出文件中采购单号
excel = HandleExcel(file_path, "%E9%87%87%E8%B4%AD%E5%8D%95%E7%")
result = {"billNo": excel.read_data()[0].get("采购单号")}
# 将接口响应时间添加至结果中
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict8", bill_no)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc采购单新增验证,2295,2295-10,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_order_list"
# 第一步登录后台运营系统获取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, "url10")
request_body = commonFuc().get_business_data(module, "payload10")
# print(request_body)
"""
场景: 采购单新增验证
用例名称:采购单新增验证
输出:{"productCode":"11852135"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取采购单新增后生成的id
result = json.loads(result.content)
# print(result)
purchase_id = result["data"]
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 查询数据库新增采购单对应的商品code
sql = "SELECT t.product_code FROM `cmdc-order`.tc_purchase_entry t WHERE purchase_id = {}".format(purchase_id)
product_code = mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]
# 实际结果
result = {"productCode": product_code}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
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采购数量不能为空_采购单新增,2295,2295-11,sit,bs
主数据平台:后台运营系统采购单新增接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_order_list"
# 第一步登录后台运营系统获取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, "url11")
request_body = commonFuc().get_business_data(module, "payload11")
# print(request_body)
"""
场景: 采购数量不能为空_采购单新增
用例名称:采购数量不能为空_采购单新增
输出:{"success":false,"code":"500","message":"采购数量不能为空","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, json=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, "checkDict11")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc采购明细不能为空_采购单新增,2295,2295-12,sit,bs
主数据平台:后台运营系统采购单新增接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_order_list"
# 第一步登录后台运营系统获取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, "url12")
request_body = commonFuc().get_business_data(module, "payload12")
# print(request_body)
"""
场景: 采购明细不能为空_采购单新增
用例名称:采购明细不能为空_采购单新增
输出:{"success":false,"code":"500","message":"采购单明细不能为空","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, json=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, "checkDict12")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc附件上传功能验证_代客下单,2295,2295-92,sit,be
主数据平台:后台运营系统附件上传功能验证_代客下单接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
import os
module = "cmdc_order_list"
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username_be")
password = commonFuc().get_business_data(module, "password_be")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers_file_1", cmdc_access_token)
print(headers)
# 获取文件地址
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, "url92")
print(url)
# 获取文件
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)
print(result)
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict92")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
file.close()
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc验证需求单是否被占用,2295,2295-98,sit,bs
主数据平台:后台运营系统验证需求单是否被占用接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
from common.db.db import mySql
import random
import requests
import json
module = "cmdc_order_list"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password2")
# 获取登录后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, "url_list")
request_body = commonFuc().get_business_data(module, "payload_list")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
demand_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取需求单信息
demandId = result["data"]["list"][demand_random]["demandId"]
# 第三步获取需求单详情信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url98")
request_body = commonFuc().get_business_data(module, "payload98", demandId)
"""
场景: 验证需求单是否被占用
用例名称:验证需求单是否被占用
输出:{"data":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 查询数据库中对应需求单编辑状态
sql = "SELECT t.isEdit FROM `cmdc-order`.tc_demand t WHERE demandId = {}".format(demandId)
is_edit = mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]
# 将接口响应时间添加至result
result = json.loads(result.content)
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict98", is_edit)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_配货单列表获取,2290,2250-02,sit,bs
主数据平台:运营后台管理系统配货单列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_order_merge"
# 第一步登录后台运营系统获取token信息
username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password2")
# 获取登录后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)
# print(result)
# 此函数用于当x为none时,进行空字符串替换
def func(x):
if x is None:
x = ""
return x
else:
return x
# 生成随机数
distribution_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取配货单信息
distribution_id = func(result["data"]["list"][distribution_random]["distributionId"])
demand_parent_code = func(result["data"]["list"][distribution_random]["demandParentCode"])
demand_code = func(result["data"]["list"][distribution_random]["demandCode"])
distribution_code = func(result["data"]["list"][distribution_random]["distributionCode"])
customer_code = func(result["data"]["list"][distribution_random]["customerCode"])
audit_by_name = func(result["data"]["list"][distribution_random]["auditByName"])
product_line_name = func(result["data"]["list"][distribution_random]["productLineName"])
distribution_status = func(result["data"]["list"][distribution_random]["distributionStatus"])
push_type = func(result["data"]["list"][distribution_random]["pushType"])
is_merge = func(result["data"]["list"][distribution_random]["isMerge"])
merge_version_code = func(result["data"]["list"][distribution_random]["mergeVersionCode"])
out_code = func(result["data"]["list"][distribution_random]["soCode"])
promotion_type = func(result["data"]["list"][distribution_random]["promotionType"])
jde_type = func(result["data"]["list"][distribution_random]["jdeType"])
customer_name = func(result["data"]["list"][distribution_random]["customerName"])
# 第三步获取配货单详情
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url5")
request_body = commonFuc().get_business_data(module, "payload5", distribution_id)
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
if result["success"]:
# 获取商品信息
product_random = random.randint(0, len(result["data"]["distributionDetailList"]) - 1)
productCodeList = func(result["data"]["distributionDetailList"][product_random]["productCode"])
materialCodeList = func(result["data"]["distributionDetailList"][product_random]["materialCode"])
optionStr = func(result["data"]["distributionDetailList"][product_random]["optionStr"])
isGroupSign = ""
# 第四步进行列表查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url4")
request_body = commonFuc().get_business_data(module, "payload4", demand_parent_code, demand_code, distribution_code,
customer_code, audit_by_name, product_line_name, distribution_status,
push_type, productCodeList, materialCodeList, jde_type, is_merge,
optionStr, customer_name, promotion_type, isGroupSign,
merge_version_code, out_code)
print(request_body)
"""
场景: 列表查询条件验证_配货单列表获取
用例名称:列表查询条件验证_配货单列表获取
输出:{"demandParentCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=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, "checkDict4", demand_parent_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict4", demand_parent_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
...@@ -15,32 +15,34 @@ import json ...@@ -15,32 +15,34 @@ import json
module = "cmdc_order_merge" module = "cmdc_order_merge"
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username1") username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password1") password = commonFuc().get_business_data(module, "password2")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 设置需要查询的商品编码 # 设置需要查询的商品编码
product_code_random = "16518884" product_code_random = "14384307"
# 模糊查询商品编码信息 # 模糊查询商品编码信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3")
request_body = commonFuc().get_business_data(module, "payload3", product_code_random) request_body = commonFuc().get_business_data(module, "payload3", product_code_random)
""" """
场景: 验证模糊查询客户信息接口连通性 场景: 验证模糊查询商品编码信息接口连通性
用例名称:模糊查询客户信息 用例名称:模糊查询商品编码信息
输出:{"productCode":"%s"} 输出:{"productCode":"%s"}
""" """
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content) result = json.loads(result.content)
print(result) # print(result)
# 获取查询结果中商品编码信息 # 获取查询结果中商品编码信息
result = {"productCode": result["data"][0]["productCode"]} result = {"productCode": result["data"][0]["productCode"]}
# print(result) # print(result)
result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3", product_code_random) check_dict = commonFuc().get_business_data(module, "checkDict3", product_code_random)
# print(check_dict) # print(check_dict)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
__author__ = "liguangyu" __author__ = "liguangyu"
""" """
case_tag:cmdc_api,cmdc模糊查询客户信息,2290,2250-03,sit,bs case_tag:cmdc_api,cmdc模糊查询客户信息_配货单列表,2290,2250-03,sit,bs
主数据平台:运营后台管理系统查询客户信息接口 主数据平台:运营后台管理系统查询客户信息接口
""" """
...@@ -15,8 +15,8 @@ import json ...@@ -15,8 +15,8 @@ import json
module = "cmdc_order_merge" module = "cmdc_order_merge"
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username1") username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password1") password = commonFuc().get_business_data(module, "password2")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
...@@ -30,19 +30,21 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_random ...@@ -30,19 +30,21 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_random
""" """
场景: 验证模糊查询客户信息接口连通性 场景: 验证模糊查询客户信息接口连通性
用例名称:模糊查询客户信息 用例名称:模糊查询客户信息_配货单列表
输出:{"cusCompanyName":"%s"} 输出:{"cusCompanyName":"%s"}
""" """
# 发送请求 # 发送请求
result = requests.get(url, params=request_body, headers=headers) result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content) result = json.loads(result.content)
# print(result)
# 获取客户信息中cusCompanyName # 获取客户信息中cusCompanyName
result = {"cusCompanyName": result["data"][0]["cusCompanyName"][:2]} result = {"cusCompanyName": result["data"][0]["cusCompanyName"][:2]}
# print(result) result["api_time"] = api_time
print(result)
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2", customer_random) check_dict = commonFuc().get_business_data(module, "checkDict2", customer_random)
# print(check_dict) print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc模糊查询物料编码,2290,2250-05,sit,bs
主数据平台:运营后台管理系统模糊查询物料编码接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_order_merge"
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password2")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 设置需要查询的模糊字段
material_code_random = "TPVL200"
# 模糊查询物料编码
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url6")
request_body = commonFuc().get_business_data(module, "payload6", material_code_random)
"""
场景: 验证模糊查询物料编码接口连通性
用例名称:模糊查询物料编码
输出:{"data":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
# 获取查询出的物料编码
result = {"data": result["data"]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict6", material_code_random)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取电商配货详情,2290,2250-01,sit,bs
主数据平台:运营后台管理系统获取电商配货详情接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import random
import json
module = "cmdc_order_merge"
# 第一步获取登录所需账号密码
username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password2")
# 获取登录后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)
# 生成随机数
dis_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取配货信息
distri_bution_id = result["data"]["list"][dis_random]["distributionId"]
# 第三步获取配货单详情
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url5")
request_body = commonFuc().get_business_data(module, "payload5", distri_bution_id)
"""
场景: 验证获取电商配货详情接口连通性
用例名称:获取电商配货详情
输出:{"distributionId":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
if result["success"]:
# 获取详情页中distributionId
result = {"distributionId": result["data"]["distributionId"]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict5", distri_bution_id)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict5", distri_bution_id)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
...@@ -38,10 +38,13 @@ request_body = commonFuc().get_business_data(module, "payload1") ...@@ -38,10 +38,13 @@ request_body = commonFuc().get_business_data(module, "payload1")
""" """
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content) result = json.loads(result.content)
# print(result) # print(result)
# 获取列表中配货单数量 # 获取列表中配货单数量
result = {"total": result["data"]["total"]} result = {"total": result["data"]["total"]}
result["api_time"] = api_time
# 查询数据库中对应公司对应的账号信息 # 查询数据库中对应公司对应的账号信息
sql = "SELECT count(t.distributionId) FROM `cmdc-order`.tc_distributionorder t WHERE companyCode = 00111" sql = "SELECT count(t.distributionId) FROM `cmdc-order`.tc_distributionorder t WHERE companyCode = 00111"
......
...@@ -55,8 +55,10 @@ request_body = commonFuc().get_business_data(module, "payload6", product_id, reb ...@@ -55,8 +55,10 @@ request_body = commonFuc().get_business_data(module, "payload6", product_id, reb
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
if result["success"]: if result["success"]:
# 获取查询结果中商品code # 获取查询结果中商品code
result = {"data": result["data"]} result = {"data": result["data"]}
......
...@@ -15,8 +15,8 @@ import json ...@@ -15,8 +15,8 @@ import json
module = "cmdc_product" module = "cmdc_product"
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username1") username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password1") password = commonFuc().get_business_data(module, "password2")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
...@@ -47,8 +47,10 @@ request_body = commonFuc().get_business_data(module, "payload59", product_code, ...@@ -47,8 +47,10 @@ request_body = commonFuc().get_business_data(module, "payload59", product_code,
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
if result["success"]: if result["success"]:
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict59") check_dict = commonFuc().get_business_data(module, "checkDict59")
......
...@@ -18,8 +18,8 @@ import os ...@@ -18,8 +18,8 @@ import os
module = "cmdc_product" module = "cmdc_product"
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username1") username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password1") password = commonFuc().get_business_data(module, "password2")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers_file", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers_file", cmdc_access_token)
...@@ -64,8 +64,10 @@ files = {"file": file} ...@@ -64,8 +64,10 @@ files = {"file": file}
""" """
# 发送请求 # 发送请求
result = requests.post(url, files=files, headers=headers) result = requests.post(url, files=files, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
if result["success"]: if result["success"]:
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict60") check_dict = commonFuc().get_business_data(module, "checkDict60")
......
...@@ -15,8 +15,8 @@ import json ...@@ -15,8 +15,8 @@ import json
module = "cmdc_product" module = "cmdc_product"
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username1") username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password1") password = commonFuc().get_business_data(module, "password2")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
...@@ -46,8 +46,10 @@ request_body = commonFuc().get_business_data(module, "payload61", product_packag ...@@ -46,8 +46,10 @@ request_body = commonFuc().get_business_data(module, "payload61", product_packag
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict61") check_dict = commonFuc().get_business_data(module, "checkDict61")
......
...@@ -15,8 +15,8 @@ import json ...@@ -15,8 +15,8 @@ import json
module = "cmdc_product" module = "cmdc_product"
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username1") username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password1") password = commonFuc().get_business_data(module, "password2")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
...@@ -46,8 +46,10 @@ request_body = commonFuc().get_business_data(module, "payload62", product_packag ...@@ -46,8 +46,10 @@ request_body = commonFuc().get_business_data(module, "payload62", product_packag
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict62") check_dict = commonFuc().get_business_data(module, "checkDict62")
......
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