def test_invalid_already_unpinned(channel_user_message_pin): owner = channel_user_message_pin unpinned_message = message_send(owner['token'], owner['c_id'], "Unpinned message") # Unpin the same message with pytest.raises(InputError): message_unpin(owner['token'], unpinned_message['message_id'])
def test_valid_message_unpin_flockr_owner(channel_user_message_pin): owner = channel_user_message_pin message = search(owner['token'], "Test Message 1")['messages'] assert message[0]['is_pinned'] message_unpin(owner['flockr_owner_token'], owner['message_id']) message = search(owner['token'], "Test Message 1")['messages'] assert not message[0]['is_pinned']
def test_invalid_external_user_unpin(channel_user_message_pin): owner = channel_user_message_pin 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_unpin(member['token'], owner['message_id'])
def message_unpin_flask(): payload = request.get_json() token = payload['token'] message_id = payload['message_id'] return dumps(m.message_unpin(token, message_id))
def test_invalid_message_id(channel_user_message_pin): owner = channel_user_message_pin invalid_m_id = -1 with pytest.raises(InputError): message_unpin(owner['token'], invalid_m_id)
def test_invalid_token(channel_user_message_pin): owner = channel_user_message_pin invalid_token = token_hash(2) with pytest.raises(AccessError): message_unpin(invalid_token, owner['message_id'])