Example #1
0
def test_message_pin_flockr_owner(channel_user_message):
    owner = channel_user_message

    message = search(owner['token'], "Test Message 1")['messages']
    assert not message[0]['is_pinned']

    message_pin(owner['flockr_owner_token'], owner['message_id'])

    message = search(owner['token'], "Test Message 1")['messages']
    assert message[0]['is_pinned']
Example #2
0
def test_external_user_pin(channel_user_message):
    owner = channel_user_message

    auth_register("*****@*****.**", "password", "Firstname", "Lastname")
    member = auth_login("*****@*****.**", "password")

    owner_channel = channel_details(owner['token'], owner['c_id'])
    assert member['u_id'] not in owner_channel['all_members']

    with pytest.raises(AccessError):
        message_pin(member['token'], owner['message_id'])
Example #3
0
def test_already_pinned(channel_user_message):
    owner = channel_user_message

    message = search(owner['token'], "Test Message 1")['messages']
    assert not message[0]['is_pinned']

    message_pin(owner['token'], owner['message_id'])

    message = search(owner['token'], "Test Message 1")['messages']
    assert message[0]['is_pinned']

    # Pin the same message
    with pytest.raises(InputError):
        message_pin(owner['token'], owner['message_id'])
Example #4
0
def message_pin_flask():
    payload = request.get_json()

    token = payload['token']
    message_id = payload['message_id']

    return dumps(m.message_pin(token, message_id))
Example #5
0
def channel_user_message_pin():
    clear()
    flockr_owner = auth_register("*****@*****.**", "password", "John",
                                 "Doe")

    auth_register("*****@*****.**", "password", "Firstname", "Lastname")
    owner = auth_login("*****@*****.**", "password")

    public = True
    c_id = channels_create(owner['token'], "Channel", public)
    message = message_send(owner['token'], c_id['channel_id'],
                           "Test Message 1")
    message_pin(owner['token'], message['message_id'])

    return {
        'u_id': owner['u_id'],
        'token': owner['token'],
        'flockr_owner_token': flockr_owner['token'],
        'c_id': c_id['channel_id'],
        'message_id': message['message_id']
    }
Example #6
0
def test_invalid_message_id(channel_user_message):
    owner = channel_user_message

    invalid_m_id = -1
    with pytest.raises(InputError):
        message_pin(owner['token'], invalid_m_id)
Example #7
0
def test_invalid_token(channel_user_message):
    owner = channel_user_message

    invalid_token = token_hash(2)
    with pytest.raises(AccessError):
        message_pin(invalid_token, owner['message_id'])