# -*- encoding=utf8 -*-
__author__ = "zhouniandong"

"""
case_tag:cmdc_api,cmdc多采商城植入上报全部列表,1001-2,1001-2-1,sit,bs
主数据平台:多采商城植入上报接口 
"""

from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin
import requests
import json


module = "cmdc_portal_reportbill"

# 登录多采商城添加商品至购物车列表
# 获取登录所需账号密码
username1 = commonFuc().get_business_data(module, "username")
password1 = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token1 = CmdcMaiiLogin(username1, password1).get_token()
headers1 = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token1)
# print(headers1)
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
print(url1)
request_body1 = commonFuc().get_business_data(module, "payload2")
"""
 场景:多采商城上报植入
 用例名称：多采商城植入上报全部列表(多采商城上报植入）
 输出：{"success":true,"code":"200","message":"OK","data":"ok"}
"""
# 发送请求
result1 = requests.post(url1, json=request_body1, headers=headers1)
#print("\033[031mresult1============\033[0m",result1)
#result1 = json.loads(result1.content)
# 获取接口响应时间
api_time = float(result1.elapsed.total_seconds())
result1 = json.loads(result1.content)
result1["api_time"] = api_time
print(api_time)
#print("\033[031mresult2============\033[0m",result1)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2")
#print("\033[031mcheckDict1============\033[0m",checkDict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result1)
