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 TestServiceList:
    data = BaseRequest().api_load(path_setting.VISUAL_SERVICE_LIST)
    service_list_case, service_list_data = get_ids(data, "service_list")

    @pytest.mark.parametrize("param", service_list_data, ids=service_list_case)
    def test_service_list(self, param):
        r = visual_request().service_list(param["unit_id"], param["page"], param["current_city_id"],
                                          param["order_by"], param["area"], param["tag_ids"])

        assert r["error"] == param["assert"]
        assert len(r["data"]["services"]) > 0
        assert r["data"]["services"][0]["spu_id"] is not None
        assert r["data"]["services"][0]["sku_id"] is not None
        assert r["data"]["services"][0]["doctor_hospital_name"] is not None
        assert r["data"]["services"][0]["gm_url"] is not None
        assert r["data"]["services"][0]["has_coupon"] is not None
        assert r["data"]["services"][0]["has_video"] is not None
        assert r["data"]["services"][0]["short_description"] is not None
        assert r["data"]["services"][0]["sell_num"] is not None
        assert r["data"]["services"][0]["price_info"] is not None
        assert r["data"]["services"][0]["activity_tag"] is not None