# -*- encoding=utf8 -*-
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
from common.common_func import commonFuc
from common.timeUtils import timeUtils
from common.fileUtls import FileUtils
import sys

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,查询器械注册人,id2254,id2254-2,sit,on
主数据平台:器械注册人申报
"""


"""
 场景:器械注册人申报
 用例名称：器械注册人申报
 输入：name
 输出："rtn_msg": "ok"
"""
module = "mdm3_ir"
# 登录
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
print(username, password)
# 获取token和projectCode
token, projectCode, uxid, corpId,info = login_system(username, password).get_token()
# 查询器械注册人
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "registrantFromCompany_url")
print(url)
# 获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers2",
                                        commonFuc().get_business_data(module, "json_contentType"), token,
                                        projectCode)
name=commonFuc().get_business_data(module,"name1")#获取前缀name
cname=name+commonFuc().randomString(5)#随机数生成拼接企业名称
request_body = commonFuc().get_business_data(module, "payload1", corpId,cname,cname,cname)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
# print('实际值',result)
code=commonFuc().analysis_json('code', result)
check_dict = commonFuc().get_business_data(module, "checkDict")
# print('预期值',check_dict)
#断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
#断言实际结果中是否包含预期的文本
commonFuc().check_text_exist(code,result)
global_var_cname = cname