Example #1
0
def route_msg_unpin():
    token = request.form.get('token')
    msg_id = int(request.form.get('message_id'))
    return dumps(msg_unpin(token, msg_id))
Example #2
0
def test_unpin_msgid_notvalid():
    # if the message id is not valid
    with pytest.raises(ValueError):
        msg_unpin(token1, 6666)
Example #3
0
def test_already_unpinned():
    # if the message is already unpinned
    msg_id1 = data['channels'][0].messages[0].message_id
    with pytest.raises(ValueError):
        msg_unpin(token1, msg_id1)
Example #4
0
def test_notmember_unpin():
    # if the unpinner is a member of the channel
    msg_id1 = data['channels'][0].messages[0].message_id
    with pytest.raises(AccessError):
        msg_unpin(token2, msg_id1)
Example #5
0
def test_successful_unpin():
    user1 = user_from_token(token1)
    user3 = user_from_token(token3)
    msg_id1 = data['channels'][0].messages[0].message_id
    admin_userpermission_change(token1, user3.u_id, perm_admin)
    assert msg_unpin(token3, msg_id1) == {}