# NOTE: Generated By HttpRunner v3.1.4
# FROM: reverseOrder_query.har

"""
currentPage integer($int64) (query)  当前页数
pageSize integer($int64) (query) 每页记录数
qp-createTime-ge string (query) 下单初始时间
qp-createTime-le string (query) 下单结束时间
qp-orderIdOut-eq string (query) 订单编号
qp-phoneNumber-eq string (query) 手机号
qp-storeCode-in string (query) 店铺编码
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 TestCaseReverseorderQuery(HttpRunner):

    @pytest.mark.parametrize(
        "param",
        Parameters({
            "business_userName-business_password-business_verifyCode-business_regType": "${parameterize(common.csv)}",
            "store_code-currentPage-pageSize-qp_createTime_ge-qp_createTime_le-qp_orderIdOut_eq-qp_phoneNumber_eq-qp_storeCode_in-sorter": "${parameterize(testcases/api/business/order/reverseOrder_query.csv)}"
        })
    )
    def test_start(self, param) -> "HttpRunner":
        super().test_start(param)

    config = (
        Config("计算购物车中选中商品的价格")
        .base_url("${get_base_url()}")
        .variables(**{
            "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/reverseOrder/query")
            .with_params(
                **{
                    "currentPage": "$currentPage",
                    "pageSize": "$pageSize",
                    "qp-storeCode-in": "$qp_storeCode_in",
                    "qp-createTime-ge": "$qp_createTime_ge",
                    "qp-createTime-le": "$qp_createTime_le",
                    "qp-orderIdOut-eq": "$qp_orderIdOut_eq",
                    "qp-phoneNumber-eq": "$qp_phoneNumber_eq",
                    "sorter": "$sorter"
                }
            )
            .with_headers(
                **{
                    "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")
        ),
    ]


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