Commit 25f50700 authored by liguangyu06's avatar liguangyu06
Browse files

优化

parent 1dcb8d6b
...@@ -30,42 +30,43 @@ request_body = commonFuc().get_business_data(module, "payload4") ...@@ -30,42 +30,43 @@ request_body = commonFuc().get_business_data(module, "payload4")
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content) result = json.loads(result.content)
# 生成随机数 if result["data"]["list"]:
customer_random = random.randint(0, len(result["data"]["list"]) - 1) # 生成随机数
# 获取分销商库存信息 customer_random = random.randint(0, len(result["data"]["list"]) - 1)
goodsInfo = result["data"]["list"][customer_random]["customerCode"] # 获取分销商库存信息
goodsInfo = result["data"]["list"][customer_random]["customerCode"]
# 第三步进行数据导出 # 第三步进行数据导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url6") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url6")
request_body = commonFuc().get_business_data(module, "payload6", goodsInfo) request_body = commonFuc().get_business_data(module, "payload6", goodsInfo)
""" """
场景: 批量导出功能验证_分销商库存上报列表 场景: 批量导出功能验证_分销商库存上报列表
用例名称:批量导出功能验证_分销商库存上报列表 用例名称:批量导出功能验证_分销商库存上报列表
输出:{"customerCode":"%s"} 输出:{"customerCode":"%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()) 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__))))) 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" file_path = BASE_DIR + "/data/cmdc_files/分销商库存明细.xlsx"
# 获取到导出文件存入cmdc_files文件中 # 获取到导出文件存入cmdc_files文件中
with open(file_path, 'wb') as f: with open(file_path, 'wb') as f:
f.write(result.content) f.write(result.content)
# 获取导出文件中分销商库存信息 # 获取导出文件中分销商库存信息
excel = HandleExcel(file_path, "Sheet1") excel = HandleExcel(file_path, "Sheet1")
result = {"customerCode": excel.read_data()[0].get("分销商编码")} result = {"customerCode": excel.read_data()[0].get("分销商编码")}
# 将接口响应时间添加至result # 将接口响应时间添加至result
result["api_time"] = api_time result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict6", goodsInfo) check_dict = commonFuc().get_business_data(module, "checkDict6", goodsInfo)
# print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) 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