import pytest

import path_setting
from all_backend_api.visual_request import visual_request
from ids_list import get_ids
from in_common.base_request import BaseRequest


class TestUnitFilter:
    data = BaseRequest().api_load(path_setting.VISUAL_UNIT_FILTER)
    unit_filter_case, unit_filter_data = get_ids(data, "unit_filter")

    @pytest.mark.parametrize("param", unit_filter_data, ids=unit_filter_case)
    def test_unit_filter(self, param):
        r = visual_request().unit_filter(param["unit_id"])

        assert r["error"] == param["assert"]
        assert r["data"]["field"] is not None
        assert r["data"]["order"] is not None
        assert r["data"]["areas"] is not None
