# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test66
# FileName:      test_dem.py
# Author:       lao_zhao
# Datetime:     2025/5/8 10:21
# Description:
# 
# ---------------------------------------------------------------------------
import allure
import pytest
from faker import Faker

data = Faker(locale="zh_cn")

depend_data = {}


@allure.epic("BPM项目-场景测试")
@allure.feature("维度管理")
@allure.story("添加维度")
@allure.title("正向用例")
@allure.severity("高")
@pytest.mark.dependency(depends=['test_case/test_bpm_dependency/test_auth.py::TestAuth::test_login'], scope="session")
def test_add_dem(req_fix):
    dem_name = data.company()
    dem_code = data.phone_number()
    add_dem_data = {"name": dem_name,"code": dem_code,"description":""}
    add_dem_url = 'http://36.139.193.99:8088/api/demension/v1/dem/addDem'
    res = req_fix.bpm_session.request(method="post", url=add_dem_url, json=add_dem_data)
    assert "添加维度成功" in res.text
    depend_data["demCode"] = dem_code


# @pytest.mark.dependency(depends=['test_bpm/test_dem.py::test_add_dem'], scope="session")
# def test_get_dem_msg(req_fix, depend_data_fix):
#     get_dem_msg_url = 'http://36.139.193.99:8088/api/demension/v1/dem/getDem'
#     get_dem_msg_data = {"code": depend_data["demCode"]}
#     res = req_fix.bpm_session.request(method="get", url=get_dem_msg_url, params=get_dem_msg_data)
#     assert '"isDelete":"0"' in res.text
#     dem_id = res.json()['id']
#     depend_data_fix["DEMID"] = dem_id


@allure.epic("BPM项目-场景测试")
@allure.feature("维度管理")
@allure.story("根据维度编码获取维度信息")
@allure.title("正向用例")
@allure.severity("高")
@pytest.mark.dependency(depends=['test_case/test_bpm_dependency/test_dem.py::test_add_dem'], scope="session")
def test_get_dem_msg(req_fix, set_depend_data_fix):
    get_dem_msg_url = 'http://36.139.193.99:8088/api/demension/v1/dem/getDem'
    get_dem_msg_data = {"code": depend_data["demCode"]}
    res = req_fix.bpm_session.request(method="get", url=get_dem_msg_url, params=get_dem_msg_data)
    assert '"isDelete":"0"' in res.text
    dem_id = res.json()['id']
    set_depend_data_fix("DEMID", dem_id)