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

"""
case_tag:cmdc_api,cmdc需求单获取失败,2250,2250-21,sit,bs
主数据平台:运营后台管理系统需求单列表接口 
"""

from common.common_func import commonFuc
import requests
import json


module = "cmdc_demand_list"

# 获取已失效的token
headers = commonFuc().get_business_data(module, "json_headers")

# 获取需求单列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body = commonFuc().get_business_data(module, "payload")

"""
 场景:用户信息过期或获取失败，无法访问需求列表
 用例名称：需求单-获取用户信息失败
 输出：{"code":"401","message":"Unauthorized","success":false}
"""

# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content)
result["api_time"] = api_time

# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)