test_proxy_health.py 2.12 KB
Newer Older
lcn's avatar
lcn committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
import json
import pytest
from unify_api.tests.constants_t import TOKEN, HTTP_PREFIX
from pot_libs.aiohttp_util.aiohttp_utils import AioHttpUtils


@pytest.mark.parametrize('data', [
    {
        "month": "2020-10",
        "cids": [66, 73, 74],
        "product": 0,
        "page_size": 10,
        "page_num": 1,
        "sort_field": "health_exp, volt_hr, curr_hr, ubl, ibl, volt_dev, "
                      "freq_dev",
        "sort_direction": "desc, asc"
    },
    {
        "month": "2020-10",
        "cids": [66, 73, 74],
        "product": 0,
        "page_size": 20,
        "page_num": 1,
        "sort_field": "health_exp, volt_hr, curr_hr, ubl, ibl, volt_dev, "
                      "freq_dev",
        "sort_direction": "desc, asc"
    }
])
@pytest.mark.asyncio
async def test_health_count_info(data):
    """
    安电u管理版本-用电健康-上方统计数据接
    """
    resp_str, status = await AioHttpUtils().post(
        url=f"{HTTP_PREFIX}/unify-api/electric/proxy-health"
            f"/health-count-info",
        data=data,
        timeout=10,
        headers={"Authorization": f"Bearer {TOKEN}"}
    )
    assert status == 200
    resp_str = json.loads(resp_str)
    assert all([resp_str["data"]["total_point_cnt"],
                resp_str["data"]["health_level"],
                resp_str["data"]["health_problem"]])


@pytest.mark.parametrize('data', [
    {
        "month": "2020-10",
        "cids": [66, 73, 74],
        "product": 0,
        "page_size": 10,
        "page_num": 1,
        "sort_field": "health_exp, volt_hr, curr_hr, ubl, ibl, volt_dev, "
                      "freq_dev",
        "sort_direction": "desc, asc"
    },
])
@pytest.mark.asyncio
async def test_health_list(data):
    """安电u管理版-用电健康-获取月度列表数据"""
    resp_str, status = await AioHttpUtils().post(
        url=f"{HTTP_PREFIX}/unify-api/electric/proxy-health"
            f"/health-list",
        data=data,
        timeout=10,
        headers={"Authorization": f"Bearer {TOKEN}"}
    )
    assert status == 200
    resp_str = json.loads(resp_str)
    assert resp_str["data"]["total"] == len(resp_str["data"]["rows"])