import pytest

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

#医院主页搜索
class TestHospitalSearch:
    data = BaseRequest().api_load(path_setting.HOSPITALSEARCH)
    hospitalsearch_case, hospitalsearch_data = get_ids(data, "hospital_search")

    @pytest.mark.parametrize("param", hospitalsearch_data, ids=hospitalsearch_case)
    def test_hospital_search(self, param):
        print(param['query'])
        r = janus_request().hospital_search(param["query"], param["device_id"], param["hospital_id"], param["current_city_id"], param["version"], param["offset"])
        if r["error"] == 0:
            assert len(r["data"]["search_skus"]) != param["assert1"]
            assert len(r["data"]["search_skus"]) == param["assert2"]
        if r["error"] == 1:
            assert r["message"] == param["assert"]
