Esempio n. 1
0
def test_message_pin():
    '''
    Function tests for message_pin
    '''
    #Initialisation
    global_var.initialise_all()

    #Create users
    owner = auth_functions.auth_register("*****@*****.**", "pass123", \
         "Sally", "Bob")
    assert owner == {"u_id": 0, "token": encode_token_for_u_id(0)}
    owner_token = owner["token"]

    user = auth_functions.auth_register("*****@*****.**", "pass123", \
         "Rayden", "Smith")
    token = user["token"]

    #owner that creates the channel and so is the owner
    channel = channel_functions.channels_create(owner_token, "Name", True)
    channel_id = channel["channel_id"]

    #user joins the channel
    channel_functions.channel_join(token, channel_id)

    #user sends 3 messages
    assert funcs.message_send(token, channel_id, "This is a valid message") \
         == {"message_id" : 0}
    assert funcs.message_send(token, channel_id, \
         "This is another valid message") == {"message_id" : 1}
    assert funcs.message_send(owner_token, channel_id, \
         "This is not your message") == {"message_id" : 2}
    #Init finished

    #A invalid token is sent to the function
    # (A invalid user is trying to use the function)
    with pytest.raises(AccessError, match="Invalid token"):
        funcs.message_pin("111111", 0)

    #A user is not an admin
    with pytest.raises(ValueError, match="User is not an admin"):
        funcs.message_pin(token, 0)

    #A admin user successfully pins a message
    assert funcs.message_pin(owner_token, 0) == {}

    #Message is invalid based on message_id
    with pytest.raises(ValueError, match="Message does not exist"):
        funcs.message_pin(owner_token, -1)

    #Message is already pinned
    with pytest.raises(ValueError, match="Message is currently pinned"):
        funcs.message_pin(owner_token, 0)

    #Admin leaves channel
    channel_functions.channel_leave(owner_token, channel_id)

    #Admin is not a member of the channel
    with pytest.raises(AccessError, match=\
         "Authorised user is not a member of the channel"):
        funcs.message_pin(owner_token, 1)
def test_search_multi_channel():
    '''
    Testing successful case of being able to obtain messages from multiple
    channels that the user is apart of
    '''
    # Initialising
    global_var.initialise_all()

    # Creating user
    user = auth_register('*****@*****.**', 'password', 'search', 'test')
    token = get_user_token_by_u_id(user["u_id"])

    # Creating channel 1
    channel1 = channels_create(token, "chat1", True)
    channel1_id = channel1["channel_id"]

    # Creating channel 2
    channel2 = channels_create(token, "chat2", True)
    channel2_id = channel2["channel_id"]

    # Adding messages to channel
    message_send(token, channel1_id, "121")
    message_send(token, channel2_id, "321")

    # Search
    messages = search.search(token, '21')

    # Checking if messages obtained
    assert messages["messages"][0]["message"] == "121"
    assert messages["messages"][0]["u_id"] == user["u_id"]
    assert messages["messages"][1]["message"] == "321"

    # Ensuring that no other messages are obtained
    with pytest.raises(IndexError, match="list index out of range"):
        message = messages["messages"][2]
Esempio n. 3
0
def test_message_react():
    '''
    Function tests for message_react
    '''
    #Initialisation
    global_var.initialise_all()

    user = auth_functions.auth_register("*****@*****.**", "pass123", \
         "Rayden", "Smith")
    token = user["token"]

    user_2 = auth_functions.auth_register("*****@*****.**", "password", \
        "Bob", "Sally")
    token_2 = user_2["token"]

    #User creates a channel
    channel = channel_functions.channels_create(token, "Name", True)
    channel_id = channel["channel_id"]

    #user sends 3 messages
    assert funcs.message_send(token, channel_id, "This is a valid message") \
         == {"message_id" : 0}
    assert funcs.message_send(token, channel_id, \
         "This is another valid message") == {"message_id" : 1}
    assert funcs.message_send(token, channel_id, \
         "This is your message") == {"message_id" : 2}
    #Initialisation finished

    # User not a member of channel
    with pytest.raises(AccessError, match=\
    "Authorised user is not a member of the channel"):
        funcs.message_react(token_2, 0, LIKE_REACT)

    channel_functions.channel_join(token_2, channel_id)

    #An invalid token is sent to the function
    with pytest.raises(AccessError, match="Invalid token"):
        funcs.message_react("111111", 0, LIKE_REACT)

    #A user successfully reacts
    assert funcs.message_react(token, 0, LIKE_REACT) == {}

    #A user successfully reacts - with a different react (Not implemented in frontend)
    assert funcs.message_react(token, 0, HEART_REACT) == {}

    #Another user also reacts to the same message
    assert funcs.message_react(token_2, 0, LIKE_REACT) == {}

    #An user tries to react to a invalid message based on message_id
    with pytest.raises(ValueError, match="Message does not exist"):
        funcs.message_react(token, -1, LIKE_REACT)

    #An user tries to react to a message already reacted to
    with pytest.raises(ValueError, match="Message contains an active react"):
        funcs.message_react(token, 0, LIKE_REACT)

    #An user uses a invalid react id
    with pytest.raises(ValueError, match="Invalid React ID"):
        funcs.message_react(token, 1, -1)
Esempio n. 4
0
def test_message_remove():
    ''' Function tests for message_remove '''

    #Initialisation
    global_var.initialise_all()
    assert global_var.data["users"] == []
    #Create users
    owner = auth_functions.auth_register("*****@*****.**", "pass123", \
         "Sally", "Bob")
    owner_token = owner["token"]

    user = auth_functions.auth_register("*****@*****.**", "pass123", \
         "Rayden", "Smith")
    token = user["token"]
    assert global_var.data["users"] != []

    #owner creates a channel and so is the owner
    channel = channel_functions.channels_create(owner_token, "Name", True)
    assert channel == {"channel_id": 0}
    channel_id = channel["channel_id"]

    #user joins the channel
    channel_functions.channel_join(token, channel_id)

    #3 messages are sent
    assert funcs.message_send(token, channel_id, "This is a valid message") \
         == {"message_id" : 0}
    assert funcs.message_send(token, channel_id, \
         "This is another valid message") == {"message_id" : 1}
    assert funcs.message_send(owner_token, channel_id, \
         "This is not your message") == {"message_id" : 2}
    #Initialisation finished

    #A invalid token is sent to the function
    with pytest.raises(AccessError, match="Invalid token"):
        funcs.message_remove("111111", 0)

    #owner successfully removes a message
    assert funcs.message_remove(owner_token, 0) == {}

    # As message was removed, it can not be removed again
    with pytest.raises(ValueError, match="Message does not exist"):
        funcs.message_remove(owner_token, 0)

    #user successfully removes his own message
    assert funcs.message_remove(token, 1) == {}

    #A owner tries to remove a invalid message based on message_id
    with pytest.raises(ValueError, match="Message does not exist"):
        funcs.message_remove(owner_token, -1)

    #A user tries to remove a invalid message based on message_id
    with pytest.raises(ValueError, match="Message does not exist"):
        funcs.message_remove(token, -1)

    #user is unable to remove a message not his/her's
    with pytest.raises(AccessError, match="User does not have permission"):
        funcs.message_remove(token, 2)
Esempio n. 5
0
 def end_standup(self, token):
     self.in_standup = False
     self.standup_end = None
     message = ""
     for m in self.standup_messages:
         line = ': '.join([m['user'], m['message']])
         message = '\n'.join([message, line])
     self.standup_messages = []
     msg.message_send(token, self.id, message)
def test_search_one():
    '''
    Testing successful case for a search for one message
    '''

    # Initialising
    global_var.initialise_all()

    # Creating user
    user = auth_register('*****@*****.**', 'password', 'search', 'test')
    token = get_user_token_by_u_id(user["u_id"])

    # Creating channel
    channel = channels_create(token, "chat", True)
    channel_id = channel["channel_id"]

    # Adding messages to channel
    message_send(token, channel_id, "121")
    message_send(token, channel_id, "321")
    message_send(token, channel_id, "342")
    message_send(token, channel_id, "499")

    # Searching message
    messages = search.search(token, '99')

    # Checking if message obtained
    assert messages["messages"][0]["message"] == "499"
    assert messages["messages"][0]["u_id"] == user["u_id"]

    # Ensuring that no other messages are obtained
    with pytest.raises(IndexError, match="list index out of range"):
        message = messages["messages"][1]
Esempio n. 7
0
def message_send():
    '''
    Send a message from authorised_user to the channel specified by channel_id
    '''
    token = request.form.get("token")
    channel_id = to_int(request.form.get("channel_id"))
    msg = request.form.get("message")

    return dumps(message.message_send(token, channel_id, msg))
Esempio n. 8
0
def test_channel_invite():
    '''
    Testing for inviting a user to a channel
    '''

    #Initialisation
    global_var.initialise_all()

    # Create an user who owns the channel
    user1 = auth_register("*****@*****.**", "password123", \
         "Rayden", "Smith")
    token_1 = user1["token"]

    # Create user that is invited to channel
    user2 = auth_register("*****@*****.**", "thisisapassword", \
         "Bob", "Sally")
    token_2 = user2["token"]
    userid_2 = user2["u_id"]

    # Create user that will not be part of channel
    user3 = auth_register("*****@*****.**", "arandompassword", \
         "Coen", "Kevin")
    token_3 = user3["token"]

    # Create a channel
    channel = func.channels_create(token_1, "TestChannel1", True)
    channel_id = channel["channel_id"]
    # Initialisation finished

    # User2 is successfully invited to channel
    assert func.channel_invite(token_1, channel_id, userid_2) == {}

    # If the invite was successful, user2 can send a message
    assert message_send(token_2, channel_id, "A successful message") \
         == {"message_id" : 0}

    # User leaves the channel
    assert func.channel_leave(token_2, channel_id) == {}

    # User is not invited if given an invalid token
    with pytest.raises(AccessError, match="Invalid token"):
        func.channel_invite("12345", channel_id, userid_2)

    # User is not inivited if given an invalid channel_id
    with pytest.raises(ValueError, match="Channel does not exist"):
        func.channel_invite(token_1, 100, userid_2)

    # Inviting user is not apart of the channel
    with pytest.raises(AccessError, \
         match="Authorised user is not a member of the channel"):
        func.channel_invite(token_3, channel_id, userid_2)

    # If user being invited is not an user
    with pytest.raises(ValueError, match="Invalid User ID"):
        func.channel_invite(token_1, channel_id, 111111)
Esempio n. 9
0
def test_channel_leave():
    '''
    Function tests for channel_leave
    '''
    #Initialisation
    global_var.initialise_all()

    user1 = auth_register("*****@*****.**", \
    "valid_correct_password", "valid_correct_first_name", \
    "valid_correct_last_name")
    token1 = user1["token"]

    #create a channel
    channel = func.channels_create(token1, "TestChannel", True)
    channel_id = channel["channel_id"]
    # Initialisation finished

    # User is in channel so can send message
    message_send(token1, channel_id, "can send message")

    # User has left channel and so can't send messages
    assert func.channel_leave(token1, channel_id) == {}

    with pytest.raises(AccessError, \
        match="Authorised user is not a member of the channel"):
        message_send(token1, channel_id, "can't send message")

    # The function is called using a invalid token
    with pytest.raises(AccessError, match="Invalid token"):
        func.channel_leave("12345", channel_id)

    #If given an invalid channel_id
    with pytest.raises(ValueError, match="Channel does not exist"):
        func.channel_leave(token1, 100)

    # The function is called using a invalid token
    with pytest.raises(AccessError, match="Invalid token"):
        func.channel_leave("12345", channel_id)

    # User is already removed, but will not cause Error
    assert func.channel_leave(token1, channel_id) == {}
def test_search_all():
    '''
    Testing search with a search for all messages request
    '''
    # Initialising
    global_var.initialise_all()

    # Creating user
    user = auth_register('*****@*****.**', 'password', 'search', 'test')
    token = get_user_token_by_u_id(user["u_id"])

    # Creating channel
    channel = channels_create(token, "chat", True)
    channel_id = channel["channel_id"]

    # Adding messages to channel
    message_send(token, channel_id, "121")
    message_send(token, channel_id, "321")
    message_send(token, channel_id, "342")
    message_send(token, channel_id, "499")

    # Searching for all messages
    messages = search.search(token, '')

    # Checking if all messages are retrieved
    assert messages["messages"][0]["message"] == "499"
    assert messages["messages"][0]["u_id"] == user["u_id"]
    assert messages["messages"][1]["message"] == "342"
    assert not messages["messages"][1]["is_pinned"]
    assert messages["messages"][2]["message"] == "321"
    assert messages["messages"][3]["message"] == "121"
    assert messages["messages"][3]["reacts"] == [
        {
            "react_id": LIKE_REACT,
            "u_ids": [],
            "is_this_user_reacted": False
        },
        {
            "react_id": HEART_REACT,
            "u_ids": [],
            "is_this_user_reacted": False
        }
    ]

    # Ensuring that no messages after all messages retrieved
    with pytest.raises(IndexError, match="list index out of range"):
        message = messages["messages"][4]
def test_search_single_channel():
    '''
    Testing successful case for search with a channel having two messages
    and returning two messages
    '''

    # Initialising
    global_var.initialise_all()

    # Creating user
    user = auth_register('*****@*****.**', 'password', 'search', 'test')
    token = get_user_token_by_u_id(user["u_id"])

    user2 = auth_register('*****@*****.**', 'password', 'search', 'test')
    token2 = get_user_token_by_u_id(user2["u_id"])

    # Creating channel
    channel = channels_create(token, "chat", True)
    channel_id = channel["channel_id"]

    # Create channel from the second user which the searching user is not a
    # member of
    channels_create(token2, "chat", True)

    # Adding messages to channel
    message_send(token, channel_id, "121")
    message_send(token, channel_id, "321")
    message_send(token, channel_id, "342")
    message_send(token, channel_id, "499")

    # Search
    messages = search.search(token, '21')

    # Checking if messages are obtained
    assert messages["messages"][0]["message"] == "321"
    assert messages["messages"][0]["u_id"] == user["u_id"]
    assert messages["messages"][1]["message"] == "121"

    # Ensuring that no other messages are obtained
    with pytest.raises(IndexError, match="list index out of range"):
        message = messages["messages"][2]
def test_get_channel_by_message_id():
    '''
    Ensures get_channel_by_message_id returns the correct channel
    '''
    # Initalise
    global_var.initialise_all()
    # Creating a user
    user = auth.auth_register("*****@*****.**", "pass123", "Raydon", "Smith")

    token = user["token"]
    # Create a channel
    channel = channel_functions.channels_create(token, "Channel 1", True)
    channel_id = channel["channel_id"]
    # Sending one message in channel
    assert message_functions.message_send(token, channel_id, "Hello Everyone")\
        == {"message_id" : 0}
    # Check message obtain from first message
    assert helpers.get_channel_by_message_id(0).id == channel_id

    # Checking no such message_id
    assert helpers.get_channel_by_message_id(-1) is None
def test_search_no_match():
    '''
    Testing search with a search for no such message
    '''

    # Initialising
    global_var.initialise_all()

    # Creating user
    user = auth_register('*****@*****.**', 'password', 'search', 'test')
    token = get_user_token_by_u_id(user["u_id"])

    # Creating channel
    channel = channels_create(token, "chat", True)
    channel_id = channel["channel_id"]

    # Adding messages to channel
    message_send(token, channel_id, "121")
    message_send(token, channel_id, "321")
    message_send(token, channel_id, "342")
    message_send(token, channel_id, "499")

    assert search.search(token, 'hey') == {'messages': []}
def test_get_message_by_message_id():
    '''
    Ensures get_message_by_message_id returns the correct message
    '''
    # Initalise
    global_var.initialise_all()

    # Creating a user
    user = auth.auth_register("*****@*****.**", "pass123", "Raydon", "Smith")
    token = user["token"]

    # Create channel
    channel = channel_functions.channels_create(token, "Channel 1", True)
    channel_id = channel["channel_id"]
    # Send message
    assert message_functions.message_send(token, channel_id, "Hello Everyone")\
        == {"message_id" : 0}

    # Assert that channel id is the same as given by message
    assert helpers.get_message_by_message_id(0).message == "Hello Everyone"

    # Checking no such message_id
    assert helpers.get_message_by_message_id(-1) is None
Esempio n. 15
0
def test_message_edit():
    '''
    Function tests for message_edit
    '''
    #Initialisation
    global_var.initialise_all()

    #Create users
    owner = auth_functions.auth_register("*****@*****.**", "pass123", \
         "Sally", "Bob")
    owner_token = owner["token"]

    user = auth_functions.auth_register("*****@*****.**", "pass123", \
         "Rayden", "Smith")
    token = user["token"]

    #owner creates a channel and so is the owner
    channel = channel_functions.channels_create(owner_token, "Name", True)
    channel_id = channel["channel_id"]

    #user joins the channel
    channel_functions.channel_join(token, channel_id)

    #3 messages are sent
    assert funcs.message_send(token, channel_id, "This is a valid message") \
         == {"message_id" : 0}
    assert funcs.message_send(token, channel_id, \
         "This is another valid message") == {"message_id" : 1}
    assert funcs.message_send(owner_token, channel_id, \
         "This is not your message") == {"message_id" : 2}
    assert funcs.message_send(token, channel_id, \
         "This is another valid message") == {"message_id" : 3}
    #Init finished

    #A owner edits a message
    assert funcs.message_edit(owner_token, 0, "This is a valid edit") == {}

    #A user edits his own message
    assert funcs.message_edit(token, 1, "This is another valid edit") == {}

    # A user edits a message with an empty string
    assert funcs.message_edit(token, 1, "") == {}
    assert funcs.message_edit(token, 3, "     ") == {}

    #A invalid token is sent to the function
    with pytest.raises(AccessError, match="Invalid token"):
        funcs.message_edit("111111", 0, "This is a valid edit")

    #A owner tries to edit a invalid message based on message_id
    with pytest.raises(ValueError, match="Message does not exist"):
        funcs.message_edit(owner_token, -1, "This is a valid edit")

    #A user tries to edit a invalid message based on message_id
    with pytest.raises(ValueError, match="Message does not exist"):
        funcs.message_edit(token, -1, "A valid message edit")

    #A user tries to edit a message not his
    with pytest.raises(AccessError, match="User does not have permission"):
        funcs.message_edit(token, 2, "This is a valid message")

    #The edited message was too long
    with pytest.raises(ValueError, match="Message length too long"):
        funcs.message_edit(owner_token, 0, "1" + create_long_string())
Esempio n. 16
0
import pytest

import server.other_functions as OF
import server.token_functions as TF
import server.channel_functions as CF
import server.channel_helper_functions as CHF
import server.message_functions as MF
from server.global_variables import reset_data
from server.auth_functions import auth_login, auth_logout, auth_register
from server.channel_functions import channels_create

reset_data()
A = auth_register("*****@*****.**", 'HoyaLee2019', 'Hoya', 'Lee')
Pub_channel = CF.channels_create(A['token'], 'Num0', 'True')
message = MF.message_send(A['token'], Pub_channel['channel_id'], "Hello",
                          18.11)
'''If token is invalid'''


def test_token_invalid():
    token = None
    query_str = 'hello'

    with pytest.raises(TypeError):
        OF.search(token, query_str)


'''Search successfully'''


def test_search_success():
Esempio n. 17
0
def test_message_send():
    ''' Function tests for message_send '''

    #Initialisation
    global_var.initialise_all()
    assert global_var.data["users"] == []

    #Creates an user
    user = auth_functions.auth_register("*****@*****.**", "pass123", \
            "Rayden", "Smith")
    assert user == {"u_id": 0, "token": encode_token_for_u_id(0)}
    token = user["token"]
    assert global_var.data["users"] != []

    #User creates a channel
    channel = channel_functions.channels_create(token, "ChannelName", True)
    assert channel == {"channel_id": 0}
    channel_id = channel["channel_id"]
    #Initialisation finished

    #User successfully sends message to created channel
    assert funcs.message_send(token, channel_id, \
                            "This is a valid message") == {"message_id": 0}

    #A invalid token is sent to the function
    with pytest.raises(AccessError, match="Invalid token"):
        funcs.message_send("111111", channel_id, "This is a valid message")

    #The channel based on ID does not exist
    with pytest.raises(ValueError, match="Invalid Channel ID"):
        funcs.message_send(token, -1, "This is a valid message")

    #Sending a message of length 1000 is valid
    assert funcs.message_send(token, channel_id, create_long_string()) \
                            == {"message_id" : 1}

    #A message of length greater than 1000
    with pytest.raises(ValueError, match="Message length too long"):
        funcs.message_send(token, channel_id, "1" + create_long_string())

    #Thrown multiple errors, token error is caught first
    with pytest.raises(AccessError, match="Invalid token"):
        funcs.message_send("111111", -1, "1" + create_long_string())

    #User leaves channel
    channel_functions.channel_leave(token, channel_id)

    #User cannot send message to channel he is not apart of
    with pytest.raises(AccessError, \
            match="Authorised user is not a member of the channel"):
        funcs.message_send(token, channel_id, "This is a valid message")
Esempio n. 18
0
def test_channel_messages():
    '''
    Function tests for channel_messages
    '''

    #Initialisation
    global_var.initialise_all()

    user1 = auth_register("*****@*****.**", "passworuser.d", \
    "channel_messages", "test")
    user_id1 = user1["u_id"]
    token1 = user1["token"]

    user2 = auth_register("*****@*****.**", "password", \
    "channel_messages2", "test2")
    token2 = user2["token"]

    #create a channel
    channel = func.channels_create(token1, "TestChannel", True)
    channel_id = channel["channel_id"]

    channel2 = func.channels_create(token1, "TestChannel2", True)
    channel_id2 = channel2["channel_id"]
    # Initialisation finished

    # Start index is invalid as there are no message
    with pytest.raises(ValueError, match="Start index is invalid"):
        func.channel_messages(token1, channel_id, 1)

    # send a message to the channel and check that return is correct
    assert message_send(token1, channel_id, '1 message') == {"message_id": 0}

    messages = func.channel_messages(token1, channel_id, 0)

    assert messages["start"] == 0
    assert messages["end"] == -1
    assert messages["messages"][0]["message_id"] == 0
    assert messages["messages"][0]["u_id"] == user1["u_id"]
    assert messages["messages"][0]["message"] == "1 message"
    assert not messages["messages"][0]["is_pinned"]
    assert messages["messages"][0]["reacts"] == [{
        "react_id": LIKE_REACT,
        "u_ids": [],
        "is_this_user_reacted": False
    }, {
        "react_id": HEART_REACT,
        "u_ids": [],
        "is_this_user_reacted": False
    }]

    # Check details return is changed when the message is reacted and pinned
    message_react(token1, 0, 1)
    message_pin(token1, 0)

    messages = func.channel_messages(token1, channel_id, 0)
    assert messages["messages"][0]["reacts"] == [{
        "react_id": LIKE_REACT,
        "u_ids": [0],
        "is_this_user_reacted": True
    }, {
        "react_id": HEART_REACT,
        "u_ids": [],
        "is_this_user_reacted": False
    }]
    assert messages["messages"][0]["is_pinned"]

    # send a message to the channel and check that return is correct
    message_send(token1, channel_id, '2 message')

    messages = func.channel_messages(token1, channel_id, 0)
    assert messages["messages"][0]["message"] == "2 message"
    assert messages["messages"][1]["message"] == "1 message"

    # A total of 50 messages are sent
    for i in range(3, 51):
        message_send(token1, channel_id, f'{i} message')

    messages = func.channel_messages(token1, channel_id, 0)
    assert messages["start"] == 0
    assert messages["end"] == -1
    assert messages["messages"][0]["message"] == "50 message"
    assert messages["messages"][49]["message"] == "1 message"

    messages = func.channel_messages(token1, channel_id, 1)
    assert messages["start"] == 1
    assert messages["end"] == -1
    assert messages["messages"][0]["message"] == "49 message"
    assert messages["messages"][48]["message"] == "1 message"

    for i in range(0, 125):
        message_send(token1, channel_id2, f'{i}')
    messages = func.channel_messages(token1, channel_id2, 0)
    assert messages["start"] == 0
    assert messages["end"] == 50
    assert messages["messages"][0]["message"] == "124"
    assert messages["messages"][49]["message"] == "75"
    messages = func.channel_messages(token1, channel_id2, 50)
    assert messages["start"] == 50
    assert messages["end"] == 100
    assert messages["messages"][0]["message"] == "74"
    assert messages["messages"][49]["message"] == "25"
    messages = func.channel_messages(token1, channel_id2, 100)
    assert messages["start"] == 100
    assert messages["end"] == -1
    assert messages["messages"][0]["message"] == "24"
    assert messages["messages"][24]["message"] == "0"

    # Test exceptions
    with pytest.raises(ValueError, match="Channel does not exist"):
        func.channel_messages(token1, -1, 0)

    with pytest.raises(AccessError, match="Invalid token"):
        func.channel_messages("12345", channel_id, 0)

    with pytest.raises(ValueError, match="Start index is invalid"):
        func.channel_messages(token1, channel_id, 100)

    with pytest.raises(AccessError, match=\
    "Authorised user is not a member of the channel"):
        func.channel_messages(token2, channel_id, 0)