# -*- encoding=utf8 -*-
from common.timeUtils import timeUtils
from common.fileUtls import FileUtils
import sys

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,分页查询供应商产品数据,id2251,id2251-1,sit,on,2023091201
主数据平台:分页查询供应商产品数据
"""
module = "mdm3_pim"
from common.common_func import commonFuc, using
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
pro_path=commonFuc().get_pro_path()
sys.path.append(pro_path+r'\\air_case\\mdm3_ea\\a企业认领.air')
using(pro_path+r'\\air_case\\mdm3_ea\\a企业认领.air')
sys.path.append(pro_path+r'\\air_case\\mdm3_ea\\a企业锁定.air')
using(pro_path+r'\\air_case\\mdm3_ea\\a企业锁定.air')
sys.path.append(pro_path+r'\\air_case\\mdm3_ea\\企业审核.air')
using(pro_path+r'\\air_case\\mdm3_ea\\企业审核.air')
from a企业认领 import *
from a企业锁定 import *
from 企业审核 import *
"""
 场景:分页查询供应商产品数据
 用例名称：分页查询供应商产品数据
 输入：CRid
 输出："rtn_msg": "ok"
"""
# 登录
username = global_var_cname
password = commonFuc().get_business_data(module, "password")
print(username, password)
# 获取token和projectCode
token, projectCode, uxid, corpId,info = login_system(username, password).get_token()
# 分页查询供应商产品数据接口
module = "mdm3_pim"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "listVoPage_url")
print(url)
# 获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers2",
                                        commonFuc().get_business_data(module, "json_contentType"), token,
                                        projectCode)
request_body = commonFuc().get_business_data(module, "payload", corpId)

# 发送请求
result = commonFuc().http_post(url, request_body, headers)
# print('实际值',result)
code = commonFuc().analysis_json('code', result)
data = commonFuc().analysis_json('data', result)
data = commonFuc().analysis_json('data', data)
# print('aaaaaaaaaaaaaaaaaaaaaaaaaaaa',data)
# 断言实际结果中是否包含预期结果的内容
# 新注册的企业首次查询产品信息，预期结果为空
check_dict = commonFuc().get_business_data(module, "checkDict")
# print('预期值',check_dict)
commonFuc().check_text_exist(code, result)  # 检查验证码
commonFuc().check_text_exist('[]', result)  # 检查数据data为空[]
