# NOTE: Generated By HttpRunner v3.1.4
# FROM: cmsTemplate_queryTemplate.har
"""
currentPage integer($int64) (query) 当前页数
pageSize integer($int64) (query) 每页记录数
qp-bg-eq * string (query) 业务 1-商城 2-助学读物
qp-platform-eq * string (query) 渠道 1-移动端 2-pc
qp-storeCode-eq string (query) 店铺code
qp-templateName-like string (query) 模板名称
qp-templateType-eq string (query) 模板类型 0店铺首页 1二级页面
sorter string (query) 排序条件 desc-字段名或者asc-字段名
sso_sessionid string (header) sessionid
x-tenant-id * string (header) tenant Default value : 2
"""


from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase, Parameters
import pytest
from testcases.api.business.business_login_test import TestCaseBusinessLogin as Login


class TestCaseCmstemplateQuerytemplate(HttpRunner):
    @pytest.mark.parametrize(
        "param",
        Parameters({
            "business_userName-business_password-business_verifyCode-business_regType": "${parameterize(common.csv)}",
            "store_code-currentPage-pageSize-qp_bg_eq-qp_platform_eq-qp_storeCode_eq-qp_templateName_like-qp_templateType_eq-sorter": "${parameterize(testcases/api/business/cmsTemplate/cmsTemplate_queryTemplate.csv)}"
        })
    )
    def test_start(self, param) -> "HttpRunner":
        super().test_start(param)

    config = (
        Config("计算购物车中选中商品的价格")
        .base_url("${get_base_url()}")
        .variables(**{
            "x_app_id": "201",
            "x_tenant_id": "2",  # tenant Default value : 2     必填选项  header部分
        })
        .export(*["sessionId", "token", "employeeName", "employeeId", "accountName", "accountId", "accountCode"])
        .verify(False)
    )

    teststeps = [
        Step(
            RunTestCase("商家后台登录")
            .call(Login)
            .export(*["sessionId", "token", "employeeName", "employeeId", "accountName", "accountId", "accountCode"])
        ),
        Step(
            RunRequest("查询装修模板，也就是列表")
            .get("/business/api/cmsTemplate/queryTemplate")
            .with_params(
                **{
                    "qp-bg-eq": "$qp_bg_eq",
                    "qp-platform-eq": "$qp_platform_eq",
                    "qp-templateName-like": "$qp_templateName_like",
                    "pageSize": "$pageSize",
                    "currentPage": "$currentPage",
                    "qp-templateType-eq": "$qp_templateType_eq",
                    "sorter": "$sorter",
                    "qp-storeCode-eq": "$qp_storeCode_eq"
                }
            )
            .with_headers(
                **{
                    "x-app-id": "$x_app_id",
                    "x-tenant-id": "$x_tenant_id",
                    "sso_sessionid": "$sessionId",
                    "store-code": "$store_code",
                    "business-code": "$accountCode",
                    "token": "$token",
                }
            )
            .validate()
            .assert_equal("status_code", 200)
            .assert_equal('headers."Content-Type"', "application/json;charset=UTF-8")
            .assert_equal("body.code", "000000")
            .assert_equal("body.msg", "Success")
            .assert_equal("body.traceId", "")
        ),
    ]


if __name__ == "__main__":
    TestCaseCmstemplateQuerytemplate().test_start()
