import pytest

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


class TestProductDetail:
    data = BaseRequest().api_load(path_setting.JANUS_PRODUCT_DETAIL)
    product_detail_case, product_detail_data = get_ids(data, "product_detail")

    @pytest.mark.parametrize("param", product_detail_data, ids=product_detail_case)
    def test_product_detail(self, param):
        r = janus_request().product_detail(param["service_id"], param["service_item_id"], param["version"])

        if r["error"] == 0:
            assert r["error"] == param["assert_error"]
            assert r["data"]["service_hospital"]["services"] != param["assert_service_hospital"]
            assert r["data"]["doctor_user_id"] is not None
            assert r["data"]["share_data"] is not None
            assert r["data"]["service"]["service_name"] is not None
            assert r["data"]["service"]["pic"] is not None
            assert r["data"]["service"]["doctor_name"] is not None
            assert r["data"]["service"]["header_pic"] is not None
            assert r["data"]["service"]["project_type_name"] is not None
            assert r["data"]["service"]["share_content"] is not None
            assert r["data"]["service"]["short_description"] is not None
            assert r["data"]["service"]["service_id"] is not None
            assert r["data"]["service"]["distance"] is not None
            assert r["data"]["service_case"] is not None
            assert r["data"]["service_features"] is not None
            assert r["data"]["tabs"] is not None
            assert r["data"]["quick_consultation"] is not None
            assert r["data"]["is_online"] is not None
            assert r["data"]["is_multiattribute"] is not None
            assert r["data"]["can_sell"] is not None
            assert r["data"]["big_quick_consultation"] is not None
        if r["error"] == 1:
            assert r["message"] == param["assert_spu_message"]

