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获取供应商信息_补货单,31,31-30,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_31st"
# 第一步登录后台运营系统获取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, "url24")
request_body = commonFuc().get_business_data(module, "payload24")
"""
场景: 验证获取供应商信息接口连通性及数据正确性
用例名称:获取供应商信息_补货单
输出:{"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": len(result["data"])}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 查询数据库中站点对应的供应商数量
sql = "SELECT count(t.id) FROM `cmdc-user`.cmdc_vptisupluer_jde t WHERE MCCO = 00111"
total = mysql_handle.selectSql(host, port, user, pwd, "cmdc-user", sql)[0][0]
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict24", total)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取协议合同号信息_补货单,31,31-31,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_31st"
# # 第一步登录后台运营系统获取token
# username = commonFuc().get_business_data(module, "username1_be")
# password = commonFuc().get_business_data(module, "password1_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, "url25")
request_body = commonFuc().get_business_data(module, "payload25")
"""
场景: 验证获取协议合同号信息接口连通性及数据正确性
用例名称:获取协议合同号信息_补货单
输出:{"total":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取站点对应的合同协议号数量
result = json.loads(result.content)
result = {"total": len(result["data"])}
# print(result)
# 将接口响应时间添加至result
result["api_time"] = api_time
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 查询数据库中站点对应的合同协议号数量
sql = "SELECT count(t.TCUKID) FROM `cmdc-user`.cmdc_vptihtxy_jde t " \
"WHERE TCDL011 IS NOT NULL AND TCDL01 IS NOT NULL AND TCEV02 != 'Y' AND TCE8HTSX = 'P'"
total = mysql_handle.selectSql(host, port, user, pwd, "cmdc-user", sql)[0][0]
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict25", total)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取子需求单列表_补货单列表,31,31-18,sit,bs
主数据平台:后台运营系统获取子需求单列表_补货单列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import random
import requests
import json
module = "cmdc_31st"
# 第一步登录后台运营系统获取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, "url19")
request_body = commonFuc().get_business_data(module, "payload19")
"""
场景: 获取子需求单列表_补货单列表
用例名称:获取子需求单列表_补货单列表
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
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, "checkDict19")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取用户已合作站点信息,31,31-15,sit,bs
主数据平台:多采商城获取用户已合作站点信息接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
from common.db.db import mySql
import requests
import json
module = "cmdc_31st"
# 第一步获取登录多采商城所需账号密码
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, "url14")
request_body = commonFuc().get_business_data(module, "payload14")
# print(request_body)
"""
场景: 获取用户已合作站点信息
用例名称:获取用户已合作站点信息
输出:{"total":"%s"}
"""
# 发送请求
result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取用户已合作站点数量
result = json.loads(result.content)
result = {"total": len(result["data"])}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db_be")
# 查询数据库中对应采购计划修改记录数量
sql = "SELECT count(t.companyId) FROM `cmdc-user`.cmdc_company_user t WHERE userId = 69"
total = mysql_handle.selectSql(host, port, user, pwd, "cmdc-user", sql)[0][0]
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict14", total)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取登录用户信息,31,31-14,sit,bs
主数据平台:多采商城获取登录用户信息接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import requests
import json
module = "cmdc_31st"
# 第一步获取登录多采商城所需账号密码
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, "url13")
request_body = commonFuc().get_business_data(module, "payload13")
# print(request_body)
"""
场景: 获取登录用户信息
用例名称:获取登录用户信息
输出:{"userName":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取用户信息中username
result = json.loads(result.content)
result = {"userName": result["data"]["userName"]}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict13", username)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取站点列表_站点管理,31,31-10,sit,bs
主数据平台:后台运营系统站点列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_31st"
# 第一步登录后台运营系统获取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, "url7")
request_body = commonFuc().get_business_data(module, "payload7")
"""
场景: 获取站点列表_站点管理
用例名称:获取站点列表_站点管理
输出:{"success":true,"code":"200","message":"操作成功"}
"""
# 发送请求
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, "checkDict7")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取站点证照信息,31,31-12,sit,bs
主数据平台:后台运营系统获取站点证照信息接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import random
import requests
import json
module = "cmdc_31st"
# # 第一步登录后台运营系统获取token
# username = commonFuc().get_business_data(module, "username1_be1")
# password = commonFuc().get_business_data(module, "password1_be1")
# # 获取登录后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, "url9")
request_body = commonFuc().get_business_data(module, "payload9")
"""
场景: 获取站点证照信息
用例名称:获取站点证照信息
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
result = requests.get(url, params=request_body)
# 获取接口响应时间
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, "checkDict9")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取补货单列表,31,31-17,sit,bs
主数据平台:后台运营系统获取补货单列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_31st"
# 第一步登录后台运营系统获取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, "url17")
request_body = commonFuc().get_business_data(module, "payload17")
"""
场景: 获取补货单列表
用例名称:获取补货单列表
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
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, "checkDict17")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取补货单商品详情,31,31-29,sit,bs
主数据平台:后台运营系统获取补货单商品详情接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import random
import requests
import json
module = "cmdc_31st"
# 第一步登录后台运营系统获取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, "url31_1")
request_body = commonFuc().get_business_data(module, "payload31_1")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
debt_random = random.randint(0, len(result["data"]["debtProductVos"]["list"]) - 1)
# 获取商品信息
customer_code = result["data"]["debtProductVos"]["list"][debt_random]["customerCode"]
distribution_type = result["data"]["debtProductVos"]["list"][debt_random]["distributionType"]
product_code = result["data"]["debtProductVos"]["list"][debt_random]["productCode"]
seller_company_code = result["data"]["debtProductVos"]["list"][debt_random]["sellerCompanyCode"]
shipment_type = result["data"]["debtProductVos"]["list"][debt_random]["shipmentType"]
# 第三步获取补货单商品详情
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url31")
request_body = commonFuc().get_business_data(module, "payload31", customer_code, distribution_type, product_code,
seller_company_code, shipment_type)
"""
场景: 获取补货单商品详情
用例名称:获取补货单商品详情
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取补货商品信息
result = json.loads(result.content)
result = {"productCode": result["data"][0]["productCode"]}
# print(result)
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict31", product_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取补货单欠货明细,31,31-33,sit,bs
主数据平台:后台运营系统获取补货单欠货明细接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import random
import requests
import json
module = "cmdc_31st"
# 第一步登录后台运营系统获取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, "url31_1")
request_body = commonFuc().get_business_data(module, "payload31_1")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
debt_random = random.randint(0, len(result["data"]["debtProductVos"]["list"]) - 1)
# 获取商品信息
customer_code = result["data"]["debtProductVos"]["list"][debt_random]["customerCode"]
distribution_type = result["data"]["debtProductVos"]["list"][debt_random]["distributionType"]
product_code = result["data"]["debtProductVos"]["list"][debt_random]["productCode"]
seller_company_code = result["data"]["debtProductVos"]["list"][debt_random]["sellerCompanyCode"]
shipment_type = result["data"]["debtProductVos"]["list"][debt_random]["shipmentType"]
# 第三步获取补货单商品详情
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url31")
request_body = commonFuc().get_business_data(module, "payload31", customer_code, distribution_type, product_code,
seller_company_code, shipment_type)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 获取补货信息
uuid1 = result["data"][0]["uuid"]
# 第四步获取补货单欠货明细
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url32")
request_body = commonFuc().get_business_data(module, "payload32", uuid1)
"""
场景: 获取补货单欠货明细
用例名称:获取补货单欠货明细
输出:{"uuid":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取补货商品信息
result = json.loads(result.content)
result = {"uuid": result["data"][0]["uuid"]}
# print(result)
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict32", uuid1)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取补货单设置信息,31,31-16,sit,bs
主数据平台:后台运营系统获取补货单设置信息接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_31st"
# 第一步登录后台运营系统获取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, "url15")
request_body = commonFuc().get_business_data(module, "payload15")
"""
场景: 获取补货单设置信息
用例名称:获取补货单设置信息
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
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, "checkDict15")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取补货单详情信息,31,31-19,sit,bs
主数据平台:后台运营系统获取补货单详情信息接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import datetime
import random
import requests
import json
module = "cmdc_31st"
# 第一步登录后台运营系统获取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, "url17")
request_body = commonFuc().get_business_data(module, "payload17")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
rep_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取补货单信息
replenishment_code = result["data"]["list"][rep_random]["replenishmentCode"]
# 第三步获取补货单详情信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url20")
request_body = commonFuc().get_business_data(module, "payload20", replenishment_code)
"""
场景: 获取补货单详情信息
用例名称:获取补货单详情信息
输出:{"replenishmentCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取补货单信息replenishmentCode
result = json.loads(result.content)
result = {"replenishmentCode": result["data"][0]["supplierInfo"]["replenishmentCode"]}
# print(result)
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict20", replenishment_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc获取补货设置批量导入日志,31,31-26,sit,bs
主数据平台:后台运营系统获取补货设置批量导入日志接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
module = "cmdc_31st"
# 第一步登录后台运营系统获取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, "url29")
request_body = commonFuc().get_business_data(module, "payload29")
"""
场景: 获取补货设置批量导入日志
用例名称:获取补货设置批量导入日志
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
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, "checkDict29")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc补货单导出验证,31,31-20,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_31st"
# 第一步登录后台运营系统获取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, "url17")
request_body = commonFuc().get_business_data(module, "payload17")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
rep_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取补货单信息
replenishment_code = result["data"]["list"][rep_random]["replenishmentCode"]
# 第三步补货单导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url21")
request_body = commonFuc().get_business_data(module, "payload21", replenishment_code)
"""
场景: 补货单导出验证
用例名称:补货单导出验证
输出:{"replenishmentCode":"%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 = {"replenishmentCode": excel.read_data()[0].get("补货单号")}
# print(result)
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict21", replenishment_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc补货设置信息导出验证,31,31-23,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_31st"
# 第一步登录后台运营系统获取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, "url15")
request_body = commonFuc().get_business_data(module, "payload15")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
set_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取补货设置信息
product_name = result["data"]["list"][set_random]["productCode"]
# 第三步补货设置信息导出
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url23")
request_body = commonFuc().get_business_data(module, "payload23", product_name)
# print(request_body)
"""
场景: 补货设置信息导出验证
用例名称:补货设置信息导出验证
输出:{"productName":"%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 = {"productName": excel.read_data()[0].get("商品编码")}
# print(result)
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict23", product_name)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc资料上传接口验证_申请变更,31,31-4,sit,bs
主数据平台:后台运营系统资料上传接口接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
import os
module = "cmdc_31st"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers_file", cmdc_access_token)
# 获取文件地址
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/test_file.jpg"
# 进行图片附件上传操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url10")
# 获取文件
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, "checkDict10")
# 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列表查询条件验证_超发记录,32,32-15,sit,be
主数据平台:后台运营系统获取超发记录接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import datetime
import random
import json
module = "cmdc_32st"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username1_be")
password = commonFuc().get_business_data(module, "password1_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, "url14")
request_body = commonFuc().get_business_data(module, "payload14")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
flow_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取超发记录信息
custData = result["data"]["list"][flow_random]["customerCode"]
productData = result["data"]["list"][flow_random]["productName"]
demandCode = result["data"]["list"][flow_random]["demandCode"]
distributionCode = result["data"]["list"][flow_random]["distributionCode"]
startTime = result["data"]["list"][flow_random]["createTime"][:10] + " 00:00:00"
endTime = str(datetime.datetime.now().strftime("%Y-%m-%d")) + " 00:00:00"
# 第三步进行列表查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url15")
request_body = commonFuc().get_business_data(module, "payload15", custData, productData, demandCode,
distributionCode, startTime, endTime)
"""
场景: 列表查询条件验证_超发记录
用例名称:列表查询条件验证_超发记录
输出:{"productData":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
# 获取超发记录信息
result = json.loads(result.content)
result = {"productData": result["data"]["list"][0]["productName"]}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict15", productData)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc列表查询条件验证_超发配置列表,32,32-8,sit,be
主数据平台:后台运营系统获取超发配置列表接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import random
import requests
import json
module = "cmdc_32st"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username1_be")
password = commonFuc().get_business_data(module, "password1_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, "url7")
request_body = commonFuc().get_business_data(module, "payload7")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
super_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取超发配置信息
strsQuery = result["data"]["list"][super_random]["productCode"]
materialCode = result["data"]["list"][super_random]["materialCode"]
productLineCode = (result["data"]["list"][super_random]["productLineCode"] if result["data"]["list"][super_random][
"productLineCode"] else "")
# 第三步进行列表查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url8")
request_body = commonFuc().get_business_data(module, "payload8", strsQuery, materialCode, productLineCode)
# print(request_body)
"""
场景: 列表查询条件验证_超发配置列表
用例名称:列表查询条件验证_超发配置列表
输出:{"strsQuery":"%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 = {"strsQuery": result["data"]["list"][0]["productCode"]}
# 将接口响应时间添加至result
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict8", strsQuery)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc客户编码或采购协议为空_采购协议批量导入,32,32-4,sit,be
主数据平台:后台运营系统采购协议批量导入接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
import os
module = "cmdc_32st"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username1_be")
password = commonFuc().get_business_data(module, "password1_be")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers_file", cmdc_access_token)
# 获取文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/采购协议导入模板_必填字段空.xlsx"
# 第二步进行采购协议的导入操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url4")
request_body = commonFuc().get_business_data(module, "payload4")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 客户编码或采购协议为空_采购协议批量导入
用例名称:客户编码或采购协议为空_采购协议批量导入
输出:{"success":false,"code":"stock","message":"第2行客户编码或采购协议为空","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, files=files, 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, "checkDict4")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc导入不能为空校验_采购协议批量导入,32,32-3,sit,be
主数据平台:后台运营系统采购协议批量导入接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json
import os
module = "cmdc_32st"
# 第一步登录后台运营系统获取token
username = commonFuc().get_business_data(module, "username1_be")
password = commonFuc().get_business_data(module, "password1_be")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers_file", cmdc_access_token)
# 获取文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/采购协议导入模板_空.xlsx"
# 第二步进行采购协议的导入操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3")
request_body = commonFuc().get_business_data(module, "payload3")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 导入不能为空校验_采购协议批量导入
用例名称:导入不能为空校验_采购协议批量导入
输出:{"success":false,"code":"stock","message":"导入数据不能为空","data":null,"freshToken":null}
"""
# 发送请求
result = requests.post(url, files=files, 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, "checkDict3")
# 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