# Path: rocketchat_API/APIExceptions/RocketExceptions.py
# class RocketMissingParamException(Exception):
#     pass


import pytest
from rocketchat_API.APIExceptions.RocketExceptions import RocketMissingParamException
def test_im_messages(logged_rocket, recipient_user):
    im_message = logged_rocket.im_messages(username=recipient_user).json()
    assert im_message.get("success")
    im_create = logged_rocket.im_create(recipient_user).json()
    room_id = im_create.get("room").get("_id")
    im_message = logged_rocket.im_messages(room_id=room_id).json()
    assert im_message.get("success")

    with pytest.raises(RocketMissingParamException):
        logged_rocket.im_messages()


def test_im_messages_others(logged_rocket, recipient_user):
    # ToDo: Try changing the access configuration so endpoint can be successfully tested
    im_create = logged_rocket.im_create(recipient_user).json()
    room_id = im_create.get("room").get("_id")
    im_messages_others = logged_rocket.im_messages_others(room_id).json()
    assert not im_messages_others.get("success")


def test_im_files(logged_rocket, recipient_user):
    im_create = logged_rocket.im_create(recipient_user).json()
    assert im_create.get("success")

    im_files = logged_rocket.im_files(room_id=im_create.get("room").get("_id")).json()
    assert im_files.get("success")

    im_files = logged_rocket.im_files(user_name=recipient_user).json()
    assert im_files.get("success")


# Path: rocketchat_API/APIExceptions/RocketExceptions.py
# class RocketMissingParamException(Exception):
#     pass


# Path: tests/test_ims.py
import pytest
from rocketchat_API.APIExceptions.RocketExceptions import RocketMissingParamException

def test_im_messages(logged_rocket, recipient_user):
    im_message = logged_rocket.im_messages(username=recipient_user).json()
    assert im_message.get("success")
    im_create = logged_rocket.im_create(recipient_user).json()
    room_id = im_create.get("room").get("_id")
    im_message = logged_rocket.im_messages(room_id=room_id).json()
    assert im_message.get("success")

    with pytest.raises(RocketMissingParamException):
        logged_rocket.im_messages()


def test_im_messages_others(logged_rocket, recipient_user):
    # ToDo: Try changing the access configuration so endpoint can be successfully tested
    im_create = logged_rocket.im_create(recipient_user).json()
    room_id = im_create.get("room").get("_id")
    im_messages_others = logged_rocket.im_messages_others(room_id).json()
    assert not im_messages_others.get("success")


def test_im_files(logged_rocket, recipient_user):
    im_create = logged_rocket.im_create(recipient_user).json()
    assert im_create.get("success")

    im_files = logged_rocket.im_files(room_id=im_create.get("room").get("_id")).json()
    assert im_files.get("success")

    im_files = logged_rocket.im_files(user_name=recipient_user).json()
    assert im_files.get("success")


    with pytest.raises(RocketMissingParamException):