# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test64
# FileName:      test_bpm.py
# Author:       lao_zhao
# Datetime:     2024/12/26 14:30
# Description:
# 
# ---------------------------------------------------------------------------
import allure
import pytest
from APIAutoTest_v3.common.read_excel import ReadExcel
from APIAutoTest_v3 import log_decorator


case_datas = ReadExcel("zs").get_data()


class TestBPM:

    @allure.epic("BPM-张三")  # 项目名称
    @log_decorator
    @pytest.mark.parametrize("module, api, title, level, url, mime, req, case, expect, sql_type, sql, update",case_datas)
    def test_bpm(self, req_fix, module, api, title, level, url, mime, req, case, expect, sql_type, sql, update):
        allure.dynamic.feature(module)  # 模块名称
        allure.dynamic.story(api)  # 接口名称
        allure.dynamic.title(title)  # 用例标题
        allure.dynamic.severity(level)  # 用例等级

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

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