# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test66
# FileName:      test_bpm.py
# Author:       lao_zhao
# Datetime:     2025/5/9 14:30
# Description:
# 
# ---------------------------------------------------------------------------
import pytest
import allure
from APIAutoTest_v3 import log_decorator
from APIAutoTest_v3.common.read_excel import ReadExcel
from APIAutoTest_v3.common.read_system_ini import ReadSystemIni

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

class TestBPM:

    @log_decorator
    @allure.epic("BPM项目-张三")
    # @allure.feature("模块名称")
    # @allure.story("接口名称")
    # @allure.title("用例标题")
    # @allure.severity("用例的等级")
    @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):
        # 生成allure报告的结果
        allure.dynamic.feature(module)
        allure.dynamic.story(api)
        allure.dynamic.title(title)
        allure.dynamic.severity(level)
        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}")