import pytest

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


class TestSendMsg:
    data = BaseRequest().api_load(path_setting.SEND_MSG)
    sendmsg_case, sendmsg_data = get_ids(data, "send_msg")

    @pytest.mark.parametrize("param", sendmsg_data, ids=sendmsg_case)
    def test_send_msg(self, param):
        r = im_request().send_msg(param["conversation_id"], param["is_system"], param["referrer"], param["referrer_id"], param["msg_type"], param["content"], param["extra"])
        print(r)
        if r["error"] == 0:
            assert r["data"]["conversation_type"] == param["assert_conversation_type"]
            assert r["data"]["message_type"] == param["assert_message_type"]
        if r["error"] == 1:
            assert r["message"] == param["assert_message"]

