# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test66
# FileName:      test_bpm.py
# Author:       lao_zhao
# Datetime:     2025/5/9 14:30
# Description:
# 
# ---------------------------------------------------------------------------
import pytest

from API2 import log_decorator
from API2.common.read_excel import ReadExcel
from API2.common.read_system_ini import ReadSystemIni

datas = ReadExcel(ReadSystemIni().get_username("user2")).get_data()

class TestBPM:

    @log_decorator
    @pytest.mark.parametrize("module, api, title, level,req, url, mime, case, expect, sql_type, sql_data, update_key", datas)
    def test_bpm(self, req_fix, module, api, title, level,req, url, mime, case, expect, sql_type, sql_data, update_key):

        res = req_fix.request_all(req_method=req,req_url=url,req_mime=mime,case_data=case,sql_type=sql_type,sql_data=sql_data,update_key=update_key)

        try:
            for key in expect:
                assert expect[key] == res.json().get(key)
        except AssertionError:
            raise AssertionError(f"断言失败，\n\t请求的url为：{url}, \n\t用例数据为：{case}, \n\t期望数据为：{expect}, \n\t服务器返回的数据为：{res.text}")