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

"""
case_tag:cmdc_api,cmdc通过规格型号查询商品验证_结算页面,2288,2288-15,sit,bs
涉及到接口:多采商城根据商品编码查询商品信息接口
"""

from common.common_func import commonFuc
import requests
import json

module = "cmdc_order_handle"

# 规格型号
specification = "10.63cm(长)×1.88cm(宽)"
# 根据规格型号查询商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url11")
request_body = commonFuc().get_business_data(module, "payload11", specification)

"""

 场景: 验证结算页面通过规格型号查询商品信息接口连通性
 用例名称：通过规格型号查询商品验证_结算页面
 输出：{"specifications":"%s"}
"""

# 发送请求
result = requests.get(url, params=request_body)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# 获取查询结果中商品对应的规格型号
result = {"specifications": result["data"]["list"][0]["specifications"]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict11", specification)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)

