def test_message_unreact_bad(): jsonClean() # SETUP BEGIN authRegisterDic = auth_register("*****@*****.**", "validpassword", "firstname", "lastname") token = authRegisterDic['token'] u_id = authRegisterDic['u_id'] channelsCreateDic = channels_create(token, "validchannel", True) channel_id = channelsCreateDic['channel_id'] authRegisterDicOne = auth_register("*****@*****.**", "validpassword1", "firstname1", "lastname1") token_one = authRegisterDicOne['token'] u_id_one = authRegisterDicOne['u_id'] channel_join(token_one, channel_id) authRegisterDicTwo = auth_register("*****@*****.**", "validpassword2", "firstname2", "lastname2") token_two = authRegisterDicTwo['token'] u_id_two = authRegisterDicTwo['u_id'] message_send(token, channel_id, "validmessage") channelMessagesDic = channel_messages(token, channel_id, 0) message_list = channelMessagesDic["messages"] message_dic = message_list[0] message_id = message_dic["message_id"] # SETUP END message_react(token, message_id, 1) with pytest.raises(ValueError): # Testing function with user who isn't admin message_unreact(token_one, message_id, 1) # Testing function with invalid message_id message_unreact(token, "invalidmessage_id", 1) # Testing function with user who isn't part of the channel message_unreact(token_two, message_id, react_id) # Testing function with invalid react_id message_unreact(token, message_id, "invalidreact_id") message_unreact(token, message_id, 1) with pytest.raises(ValueError): # Testing function with already unreacted message_id message_unreact(token, message_id, 1) message_react(token, message_id, react_id) auth_logout(token) with pytest.raises(ValueError): # Testing function with invalid token message_unreact(token, message_id, react_id)
def test_message_unreact(): jsonClean() # SETUP BEGIN authRegisterDic = auth_register("*****@*****.**", "valid40password", "first40name", "last40name") token = authRegisterDic['token'] u_id = authRegisterDic['u_id'] channelsCreateDic = channels_create(token, "validchannel", True) channel_id = channelsCreateDic['channel_id'] authRegisterDicOne = auth_register("*****@*****.**", "valid41password", "first41name", "last41name") token_one = authRegisterDicOne['token'] u_id_one = authRegisterDicOne['u_id'] message_send(token, channel_id, "validmessage") channelMessagesDic = channel_messages(token, channel_id, 0) message_list = channelMessagesDic["messages"] message_dic = message_list[0] message_id = message_dic["message_id"] # Assuming 123 is valid react_id react_id = 123 # SETUP END message_react(token, message_id, react_id) with pytest.raises(ValueError): message_react(token, message_id, react_id) assert message_unreact(token, message_id, react_id) == {} # Testing message_react to check the message was successfully unreacted message_react(token, message_id, react_id)
def test_message_react(): jsonClean() # SETUP BEGIN authRegisterDic = auth_register("*****@*****.**", "validpassword", "firstname", "lastname") token = authRegisterDic['token'] u_id = authRegisterDic['u_id'] channelsCreateDic = channels_create(token, "validchannel", True) channel_id = channelsCreateDic['channel_id'] authRegisterDicOne = auth_register("*****@*****.**", "validpassword1", "firstname1", "lastname1") token_one = authRegisterDicOne['token'] u_id_one = authRegisterDicOne['u_id'] channel_join(token_one, channel_id) message_send(token, channel_id, "validmessage") channelMessagesDic = channel_messages(token, channel_id, 0) message_list = channelMessagesDic["messages"] message_dic = message_list[0] message_id = message_dic["message_id"] # Assuming 123 is valid react_id react_id = 123 # SETUP END assert message_react(token, message_id, react_id) == {} # Testing two users can react laugh one message assert message_react(token_one, message_id, react_id) == {} with pytest.raises(ValueError): # Testing function can't react the message for a second time message_react(token, message_id, react_id) # Testing function can unreact the message assert message_unreact(token, message_id, react_id) == {}
def wrap_message_react(): message_react(request.form.get('token'), request.form.get('message_id'), request.form.get('react_id')) return json.dumps({})