# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   python_study
# FileName:      test_bpm.py
# Author:       mwx
# Datetime:     2024/11/6 00:12
# Description:
# 
# ---------------------------------------------------------------------------
import pytest

from Interface_automation.APIAutoText_v3_1_1 import log
from Interface_automation.APIAutoText_v3_1_1.commn.read_excel import ReadExcel
from Interface_automation.APIAutoText_v3_1_1.test_case.test_mw import USERNAME


class TestBPM:
    @pytest.mark.parametrize("request_m,url_name,mime_type,data_case,data_expect,sql_type,data_sql,update_sql",ReadExcel(USERNAME).get_data())
    def test_bpm(self,request_py,request_m,url_name,mime_type,data_case,data_expect,sql_type,data_sql,update_sql):
        res = request_py.request_all(req_method=request_m,req_url=url_name,req_mime=mime_type,req_case_data=data_case,sql_type=sql_type,sql_data=data_sql,update_key=update_sql)
        print(res)
        try:
            for key in data_expect.keys():
                assert res.json().get(key) == data_expect[key]
        except AssertionError:
            log.error(f"断言失败，用例数据为：{data_case}，期望数据为：{data_case}， 服务器返回的数据为：{res.text}")
            raise AssertionError("断言失败")
        else:
            log.info(f"断言成功，用例数据为：{data_case}，期望数据为：{data_case}， 服务器返回的数据为：{res.text}")