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

Merge branch 'master' into 'main'

Master|代码更新归档

See merge request !6
parents e7e2bda7 58586362
......@@ -16,8 +16,8 @@ module = "cmdc_special_fresenius_group"
# 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
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_headers2", cmdc_access_token)
......@@ -45,6 +45,9 @@ url = commonFuc().get_api_url() + commonFuc().get_business_data(module,
# 发送请求
result = requests.get(url, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# 数据库操作
......@@ -55,7 +58,7 @@ host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询套包状态
sql = "SELECT t.status FROM `cmdc-order`.tc_fresenius_group t WHERE groupId = {}".format(group_id)
result = {"status": mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict21")
# 断言实际结果中是否包含预期结果的内容
......
......@@ -15,8 +15,8 @@ import json
module = "cmdc_special_fresenius_group"
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
username = commonFuc().get_business_data(module, "username4")
password = commonFuc().get_business_data(module, "password4")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
......@@ -33,14 +33,18 @@ request_body = commonFuc().get_business_data(module, "payload46")
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
print(result)
# 获取创建需求成功后需求单信息
demand_parent_code = result["data"]["国药集团上海医疗器械有限公司"]["demandParentCode"]
demand_parent_id = result["data"]["国药集团上海医疗器械有限公司"]["demandParentId"]
demand_parent_code = result["data"]["国药集团联合医疗器械有限公司"]["demandParentCode"]
demand_parent_id = result["data"]["国药集团联合医疗器械有限公司"]["demandParentId"]
# 实际结果
result = {"demandParentCode": demand_parent_code}
result["api_time"] = api_time
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
......@@ -52,6 +56,6 @@ sql = "SELECT t.demandParentCode FROM `cmdc-order`.tc_demand t WHERE demandParen
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict46",
mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0])
print(check_dict)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -39,21 +39,26 @@ request_body = commonFuc().get_business_data(module, "payload43")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
print(result)
# print(result)
result["api_time"] = api_time
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict43")
# # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# 查询购物车列表
# 进行站点切换
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_buyercart")
request_body = commonFuc().get_business_data(module, "payload_buyercart")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
print(result)
# print(result)
# 过滤查找添加的单品
for i in result["data"]["list"]:
......@@ -62,7 +67,8 @@ for i in result["data"]["list"]:
if j["buyerCartId"] == 19177:
result = {"groupPrice": j["groupPrice"], "timeStr": j["timeStr"], "documentNo": j["documentNo"],
"buyCartNum": 5}
print(result)
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict_buyercart")
# # 断言实际结果中是否包含预期结果的内容
......
......@@ -16,8 +16,8 @@ module = "cmdc_special_fresenius_group"
# 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
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)
......@@ -45,12 +45,18 @@ request_body = commonFuc().get_business_data(module, "payload42", fresenius_pric
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
result["api_time"] = api_time
# 进行相应判断,当success为true时,说明超限额,否则未超限额
if result["success"]:
# 获取结果中限购数量
result = {"purchaseQuantity": result["data"]["purchaseQuantity"]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict42")
# 断言实际结果中是否包含预期结果的内容
......
......@@ -19,8 +19,8 @@ module = "cmdc_special_fresenius_group"
# 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
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)
......@@ -83,7 +83,12 @@ request_body = {"manufacturerGroupName": "", "manufacturerGroupCode": "", "group
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
result["api_time"] = api_time
# print(result)
if result["success"]:
# 数据库操作
......@@ -94,10 +99,12 @@ if result["success"]:
# 数据库查询新增特价单品
sql = "SELECT t.groupId FROM `cmdc-order`.tc_fresenius_agreement_price t " \
"WHERE customerCode = {} and documentNo = '{}';".format(customer_code, ref_random)
print(sql)
# print(sql)
total = len(mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql))
result = {"total": total}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict17")
# 断言实际结果中是否包含预期结果的内容
......
......@@ -36,6 +36,9 @@ request_body = commonFuc().get_business_data(module, "payload1")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# 获取特价单品总数量
......@@ -49,6 +52,7 @@ host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询特价单品数量
sql = "SELECT t.groupId FROM `cmdc-order`.tc_fresenius_group t WHERE groupType = 1 and companyCode = 00111;"
total = len(mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql))
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1", total)
......
......@@ -32,8 +32,12 @@ request_body = commonFuc().get_business_data(module, "customer_payload")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict15")
# 断言实际结果中是否包含预期结果的内容
......
......@@ -15,8 +15,8 @@ module = "cmdc_special_fresenius_group"
# 第一步登录多采商城获取cmdc_access_token
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
username = commonFuc().get_business_data(module, "username4")
password = commonFuc().get_business_data(module, "password4")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
......@@ -39,11 +39,16 @@ request_body = commonFuc().get_business_data(module, "payload38")
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
print(result)
result = {"productCode": result["data"][0]["productCode"]}
# print(result)
# result = {"productCode": result["data"][0]["productCode"]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict38")
check_dict = commonFuc().get_business_data(module, "checkDict38_1")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
......@@ -57,6 +57,8 @@ request_body = {"groupIds": [group_id], "type": 1}
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
......@@ -65,7 +67,7 @@ host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询套包状态
sql = "SELECT t.status FROM `cmdc-order`.tc_fresenius_group t WHERE groupId = {}".format(group_id)
result = {"status": mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]}
result["api_time"] = api_time
# 获取
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict7")
......
......@@ -46,6 +46,9 @@ request_body = {"groupIds": [group_id], "type": 0, "remarks": ""}
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
......@@ -54,6 +57,7 @@ host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询套包状态
sql = "SELECT t.status FROM `cmdc-order`.tc_fresenius_group t WHERE groupId = {}".format(group_id)
result = {"status": mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql)[0][0]}
result["api_time"] = api_time
# 获取
# 获取预期结果
......
......@@ -42,7 +42,10 @@ files = {"file": file}
# 发送请求
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)
# 获取预期结果
......
......@@ -48,6 +48,8 @@ request_body = commonFuc().get_business_data(module, "payload10", demand_code)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# result = json.loads(result.content)
# print(result)
......@@ -62,7 +64,7 @@ with open(file_path, 'wb') as f:
# 获取文件中订单编号
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)
......
# -*- 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-42,sit,be
主数据平台:多采商城库存上报信息导出接口
"""
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_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, "url38")
request_body = commonFuc().get_business_data(module, "payload38")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
stock_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取库存上报信息
statistic_year = result["data"]["list"][stock_random]["statisticYear"]
# 第三步进行库存信息导出操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url41")
request_body = commonFuc().get_business_data(module, "payload41", statistic_year)
# print(request_body)
"""
场景: 库存上报信息导出验证
用例名称:库存上报信息导出验证
输出:{"statisticYear":"%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, "Sheet1")
# print(excel.read_data())
result = {"statisticYear": excel.read_data()[0].get("所属年度")}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict41", statistic_year)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc库存信息修改功能验证,2294,2294-41,sit,be
主数据平台:多采商城库存信息修改接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
from common.db.db import mySql
import random
import requests
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, "url38")
request_body = commonFuc().get_business_data(module, "payload38")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
stock_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取库存上报信息
source = result["data"]["list"][stock_random]["source"]
statistic_inv_report_id = result["data"]["list"][stock_random]["statisticInvReportId"]
inventory_cost_amount = random.randint(100, 10000)
# 第三步进行库存信息修改
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url40")
request_body = commonFuc().get_business_data(module, "payload40", statistic_inv_report_id, inventory_cost_amount,
source)
# print(request_body)
"""
场景: 库存信息修改功能验证
用例名称:库存信息修改功能验证
输出:{"inventoryCostAmount":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db_be")
# 查询数据库中库存信息对应的库存数量
sql = "SELECT t.inventoryCostAmount FROM `cmdc-cms`.cms_statistic_invreport t WHERE statisticInvReportId = {}".format(
statistic_inv_report_id)
amount = mysql_handle.selectSql(host, port, user, pwd, "cmdc-cms", sql)[0][0]
# 断言结果
result = {"inventoryCostAmount": int(amount)}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict40", inventory_cost_amount)
# 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)
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