import pytest

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


class TestV2Service:
    data = BaseRequest().api_load(path_setting.V2SERVICE)
    v2service_case, v2service_data = get_ids(data, "v2_service")

    @pytest.mark.parametrize("param", v2service_data, ids=v2service_case)
    def test_v2_service(self,param):
        r = search_request().v2_service(param['q'], param['input_type'], param['version'], param['page'], param['start_num'])
        if r["error"] == 0:
            assert len(r["data"]["services"]) == param["assert"]
        else:
            assert r["error"] == param["assert_error"]
