# -*- encoding=utf8 -*-

__author__ = "xiaohesheng"

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

from common.common_func import commonFuc
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system

module = "a2_mdm3_ea"
# 注册企业
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "CompanyRegist_url")
# #获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers",
                                        commonFuc().get_business_data(module, "json_contentType"))
print(headers)
name = commonFuc().get_business_data(module, "name1")  # 获取前缀name
cname = name + commonFuc().randomString(5)  # 随机数生成拼接企业名称
request_body = commonFuc().get_business_data(module, "payload", cname, cname, cname, cname, cname, cname)
print(request_body)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
# 获取接口返回id
id1 = commonFuc().analysis_json('id', result)

# 企业注册提交接口_认领
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "updateById_url")
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)
request_body = commonFuc().get_business_data(module, "payload1",id1)

# 发送请求
result = commonFuc().http_post(url, request_body, headers)
# # print(result)
#获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict")
print(check_dict)
#断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
#=============== 企业注册提交接口_认领结束
#企业审核接口_查询数据_开始
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "queryListPage_url")
request_body = commonFuc().get_business_data(module, "payload2",cname)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
#获取接口返回数据
code = commonFuc().analysis_json('code', result)
#断言实际结果中是否包含预期结果的内容
# commonFuc().check_result(code, result)
#断言实际结果中是否包含预期的文本
commonFuc().check_text_exist(code,result)
#===============企业注册提交接口_查询数据_结束

#企业注册提交接口_锁定_开始
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "queryAlCompanyRegistInfo_url")
request_body = commonFuc().get_business_data(module, "payload3",id1)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
#获取接口返回数据
code = commonFuc().analysis_json('code', result)
#断言实际结果中是否包含预期结果的内容
commonFuc().check_text_exist(code, result)
#===============企业注册提交接口_锁定_结束

#企业审核接口_再次查询数据_开始
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "upCompanyList_url")
request_body = commonFuc().get_business_data(module, "payload4",cname)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
#获取接口返回数据
code = commonFuc().analysis_json('code', result)
#断言实际结果中是否包含预期结果的内容
commonFuc().check_text_exist(code, result)
#===============企业注册提交接口_查询数据_结束

#企业注册提交接口_审核驳回_开始
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "updateByIdCompanyRegistBill_url")
request_body = commonFuc().get_business_data(module, "payload6",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, "checkDict2")

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


