# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test65
# FileName:      test_bpm.py
# Author:       lao_zhao
# Datetime:     2025/3/12 14:35
# Description:
# 
# ---------------------------------------------------------------------------
import pytest
from APIAutoTest_v3 import log_decorator
from APIAutoTest_v3.common.read_excel import ReadExcel
from APIAutoTest_v3.common.read_system_ini import ReadSystemIni
import allure

data = ReadExcel(ReadSystemIni().get_user_name("user3"))

class TestBPM:


    @allure.epic("BPM项目-维度管理和组织管理-王五")
    @log_decorator
    @pytest.mark.parametrize("module, api, title, level, method, url, mime, case_data, expect_data, sql_data, sql_type, update_key", data.get_data())
    def test_bpm(self, req_fix, module, api, title, level, method, url, mime, case_data, expect_data, sql_data, sql_type, update_key):
        allure.dynamic.feature(module)
        allure.dynamic.story(api)
        allure.dynamic.title(title)
        allure.dynamic.severity(level)

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

        try:
            for key in expect_data:
                assert expect_data[key] == res.json().get(key)
        except AssertionError:
            raise AssertionError(f"断言失败,请求方法为：{method}, url:{url}, 媒体类型：{mime}, 用例数据：{case_data}, 期望数据：{expect_data}, sql语句为：{sql_data}, sql语句类型：{sql_type}, 更新为key:{update_key}")