Example #1
0
def test_message_unreact_own(reset):
    a_token = register('*****@*****.**', 'pass123456', 'Alan', 'Brown')[1]
    channel_id = channels_create(a_token, 'test_public', True)
    msg0_id = message_send(a_token, channel_id, 'test message please react')
    message_react(a_token, msg0_id, 1)
    # unreacting
    message_unreact(a_token, msg0_id, 1)
    msg_list = channel_messages(a_token, channel_id, 0)[0]
    assert msg_list[0]['reacts'][0]['u_ids'] == []
    logout(a_token)
Example #2
0
def test_message_pin_owner(reset):
    a_token = register('*****@*****.**', 'pass123456', 'Admin', 'Heeblo')[1]
    channel_id = channels_create(a_token, 'test_public', True)
    msg0_id = message_send(a_token, channel_id, 'Pin this message')
    # pins the message
    message_pin(a_token, msg0_id)
    msg_list = channel_messages(a_token, channel_id, 0)[0]

    assert msg_list[0]['is_pinned']
    logout(a_token)
Example #3
0
def test_message_send_ok(reset):
    '''
    Testing sending a valid message by an authorised user
    '''
    a_token = register('*****@*****.**', 'pass123456', 'Alan', 'Brown')[1]
    channel_id = channels_create(a_token, 'test_public', True)
    message_send(a_token, channel_id, 'test message')
    msg_list = channel_messages(a_token, channel_id, 0)[0]
    assert len(msg_list) == 2  # hangman bot sends a message as well
    assert msg_list[0]['message'] == 'test message'
    logout(a_token)
Example #4
0
def test_message_pin_owner_pins_user():
    a_token = login('*****@*****.**', 'pass123456')[1]
    k_token = register('*****@*****.**', 'kenis123', 'Ken', 'Li')[1]
    channel_join(k_token, 1)
    msg1_id = message_send(k_token, 1, 'User message')
    # user a pins user k's message
    message_pin(a_token, msg1_id)

    msg_list = channel_messages(a_token, 1, 0)[0]
    assert msg_list[0]['is_pinned'] and msg_list[1]['is_pinned']
    logout(a_token)
    logout(k_token)
def test_standup_send_one_message(reset):
    '''
    A valid request to send a message to a standup
    '''
    my_id, my_token = register(
        '*****@*****.**', '1231FFF!', 'Yousif', 'Khalid')
    channel_id = channels_create(my_token, 'Yousifs Channel', is_public=True)
    standup_start(my_token, channel_id, length=3)
    standup_send(my_token, channel_id, 'Actually my first message?')
    time.sleep(3.1)
    messages = channel_messages(my_token, channel_id, start=0)[0]
    assert messages[0]['message'] == 'Actually my first message?'
    assert messages[0]['u_id'] == my_id
Example #6
0
def test_message_sendlater_threading(reset):
    '''
    Testing other requests can be processed concurrently without disturbing sendlater
    '''
    k_token = register('*****@*****.**', 'kenis123', 'Ken', 'Li')[1]
    channel_id = channels_create(k_token, 'test_public', True)
    message_sendlater(k_token, channel_id, 'sending later', time.time() + 1)
    message_send(k_token, channel_id, 'test message0')
    message_send(k_token, channel_id, 'test message1')
    time.sleep(2)
    msg_list = channel_messages(k_token, channel_id, 0)[0]
    assert len(msg_list) == 4  # hangman sends a message as well
    assert msg_list[0]['message'] == 'sending later'
    logout(k_token)
Example #7
0
def test_message_remove_own(reset):
    '''
    Testing removing a valid message by a valid authorised user
    '''
    a_token = register('*****@*****.**', 'pass123456', 'Alan', 'Brown')[1]
    channel_id = channels_create(a_token, 'test_public', True)
    msg0_id = message_send(a_token, channel_id, 'test message to be removed')
    # check list is now empty after removal
    message_remove(a_token, msg0_id)
    message_send(a_token, channel_id, 'new_test_message')
    msg_list = channel_messages(a_token, channel_id, 0)[0]
    assert len(msg_list) == 2  # hangman bot sends a message as well..
    assert msg_list[0]['message'] == 'new_test_message'
    logout(a_token)
Example #8
0
def test_message_unpin_slackr_owner_not_in_channel(reset):
    a_token = register('*****@*****.**', 'pass123456', 'Admin', 'Heeblo')[1]
    k_token = register('*****@*****.**', 'kenis123', 'Ken', 'Li')[1]
    # ken creates a channel
    k_channel_id = channels_create(k_token, 'test_public', True)
    msg0_id = message_send(k_token, k_channel_id,
                           'Kens message in his channel')
    message_pin(k_token, msg0_id)
    # admin unpins the message sent by ken
    message_unpin(a_token, msg0_id)

    msg_list = channel_messages(k_token, k_channel_id, 0)[0]
    assert not msg_list[0]['is_pinned']
    logout(a_token)
    logout(k_token)
Example #9
0
def test_message_remove_slackr_owner(reset):
    # slackr owner
    a_token = register('*****@*****.**', 'pass123456', 'Alan', 'Brown')[1]
    k_token = register('*****@*****.**', 'kenis123', 'Ken', 'Li')[1]
    # ken creates a channel
    channel_id = channels_create(k_token, 'test_public', True)
    msg0_id = message_send(k_token, channel_id, 'test message in ken channel')
    message_send(k_token, channel_id, 'test message2 in ken channel')

    message_remove(a_token, msg0_id)
    msg_list = channel_messages(k_token, channel_id, 0)[0]
    assert len(msg_list) == 2  # hangman bot sends a message at the start
    assert msg_list[0]['message'] == 'test message2 in ken channel'
    # unremoved message (2nd one sent) retains its ID
    # hangman bot sends the first msg with id 1
    assert msg_list[0]['message_id'] == 3

    logout(a_token)
    logout(k_token)
def test_user_remove_removed_message(reset):
    '''
    A removed user has all the messages he has sent removed
    '''
    _, admin_token = register(
        '*****@*****.**', 'HelloWorld', 'Yousif', 'Wang')
    u_id, u_token = register('*****@*****.**', 'HelloWorld123', 'Josh', 'Wang')
    # admin creates a channel
    channel_id = channels_create(admin_token, 'Da channel', is_public=True)
    # joining..
    channel_join(u_token, channel_id)
    # send a message
    message_send(u_token, channel_id, 'HelloWorld')
    # new user is removed
    user_remove(admin_token, u_id)
    # their message should be removed from the channel
    messages, _, _ = channel_messages(admin_token, channel_id, start=0)
    # the reason we assert 1 is because the hangman sends a message at the
    # start of channel
    assert len(messages) == 1
def test_standup_send_non_blocking(reset):
    '''
    Testing tinkering with standups does not block other things
    '''
    my_token = register('*****@*****.**',
                        '1231FFF!', 'Yousif', 'Khalid')[1]
    # creating a channel
    channel_id = channels_create(my_token, 'Yousifs Channel', is_public=True)
    # starting a standup by me
    standup_start(my_token, channel_id, length=3)
    # message sent by me
    standup_send(my_token, channel_id, 'should be last message sent pt1')
    standup_send(my_token, channel_id, 'should be last message sent pt2')

    message_send(my_token, channel_id, 'should be first message sent')
    time.sleep(3.1)
    messages = channel_messages(my_token, channel_id, start=0)[0]
    # hangman bot sends a message at the creation of the channel
    assert len(messages) == 3
    assert messages[0]['message'] == \
        'should be last message sent pt1\nshould be last message sent pt2'
def test_standup_send_two_messages(reset):
    '''
    A valid request to send two messages to a standup
    '''
    my_id, my_token = register(
        '*****@*****.**', '1231FFF!', 'Yousif', 'Khalid')
    user_token = register('*****@*****.**',
                          '2222!!!!', 'Jack', 'Robbers')[1]
    # creating a channel
    channel_id = channels_create(my_token, 'Yousifs Channel', is_public=True)
    # other user joins
    channel_join(user_token, channel_id)
    # starting a standup by me
    standup_start(my_token, channel_id, length=3)
    # message sent by me
    standup_send(my_token, channel_id, 'Actually my first message?')
    # message sent by another guy
    standup_send(user_token, channel_id, 'Jacks message!')
    time.sleep(3.1)
    messages = channel_messages(my_token, channel_id, start=0)[0]
    assert messages[0]['message'] == 'Actually my first message?\nJacks message!'
    assert messages[0]['u_id'] == my_id