コード例 #1
0
def test_message_pin_not_owner_tries():
    c_token = register('*****@*****.**', 'ssap12652', 'Chen', 'Bee')[1]
    channel_join(c_token, 1)
    msg1_id = message_send(c_token, 1, 'My own message')

    with pytest.raises(HTTPError):
        message_pin(c_token, msg1_id)
    logout(c_token)
コード例 #2
0
def test_message_unpin_invalid_message(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)

    with pytest.raises(HTTPError):
        message_unpin(a_token, msg0_id + 1)
    logout(a_token)
コード例 #3
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)
コード例 #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)
コード例 #5
0
def test_message_unpin_not_channel_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)

    # make another user who is part of channel but not owner nor slackr owner
    u_token = register('*****@*****.**', 'usersweakpw', 'Bob', 'Builder')[1]
    channel_join(u_token, channel_id)

    with pytest.raises(HTTPError):
        message_unpin(u_token, msg0_id)
    logout(a_token)
コード例 #6
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)
コード例 #7
0
def test_message_pin_not_member():
    c_token = login('*****@*****.**', 'ssap12652')[1]
    channel_leave(c_token, 1)
    with pytest.raises(HTTPError):
        message_pin(c_token, 1)
    logout(c_token)
コード例 #8
0
def test_message_pin_already_pinned():
    # recall from first test, admin already pinned their own message
    a_token = login('*****@*****.**', 'pass123456')[1]
    with pytest.raises(HTTPError):
        message_pin(a_token, 2)
    logout(a_token)
コード例 #9
0
def test_message_pin_invalid_message_id():
    a_token = login('*****@*****.**', 'pass123456')[1]
    with pytest.raises(HTTPError):
        message_pin(a_token, 35)
    logout(a_token)