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

data = Faker(locale="zh_cn")

depend_data = {}

@pytest.mark.dependency(depends=['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


@pytest.mark.dependency(depends=['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)