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

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,企业审核,id2248,id2248-3,sit,on
主数据平台:注册企业审核认领流程 
"""

from common.common_func import commonFuc
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
from airtest.core.api import using
import sys

pro_path=commonFuc().get_pro_path()
sys.path.append(pro_path+r'\\air_case\\a2_mdm3_ea\\a企业认领.air')
using(pro_path+r'\\air_case\\a2_mdm3_ea\\a企业认领.air')
from a企业认领 import *
# print('global_var_id',global_var_id)
id1=global_var_id
cname=global_var_cname
def test1():
    module = "a2_mdm3_ea"
    """
     场景:注册企业审核
     用例名称：企业审核
     输入：CRid
     输出："rtn_msg": "{"code": 0,'msg': None,'data':'审核通过'}"
    """
    # 企业注册提交接口_审核通过_开始
    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()
    #获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            projectCode, token)

    url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "auditCompanyRegistBill_url")
    request_body = commonFuc().get_business_data(module, "payload5",id1)
    # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    # print('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',result)
    #获取接口返回数据
    code = commonFuc().analysis_json('code', result)
    check_dict1 = commonFuc().get_business_data(module, "checkDict1")

    #断言实际结果中是否包含预期结果的内容
    commonFuc().check_result(check_dict1, result)
    #===============企业注册提交接口_审核通过_结束

    info=(id1,cname)
    titlename=('e_id','cname')
    #审核通过的企业名称写入文件中
    FileUtils().w_info5(info,module,'企业信息',titlename)

test1()