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

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

from common.common_func import commonFuc
import requests
import json

module = "cmdc_order_handle"

# 规格型号
material_code = "00-8800-000-10"
# 根据物料编码查询商品信息
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url13")
request_body = commonFuc().get_business_data(module, "payload13", material_code)

"""

 场景: 验证结算页面通过物料编码查询商品信息接口连通性
 用例名称：通过物料编码查询商品验证_结算页面
 输出：{"materialCode":"%s"}
"""

# 发送请求
result = requests.get(url, params=request_body)
result = json.loads(result.content)
# print(result)
# 获取查询结果中商品对应的物料编码
result = {"materialCode": result["data"]["list"][0]["materialCode"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict13", material_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)