def test_message_already_reacted(new_channel_and_user): """ Test that if a user react to a message that has already been reacted""" message = message_send(new_channel_and_user['token'], new_channel_and_user['channel_id'], 'adcd') message_react(new_channel_and_user['token'], message['message_id'], 1) with pytest.raises(InputError): message_react(new_channel_and_user['token'], message['message_id'], 1)
def test_message_unreact_invalid_react_id(new_channel_and_user): """ Test that a legal user unreact a message but with invalid react_id""" message = message_send(new_channel_and_user['token'], new_channel_and_user['channel_id'], 'adcd') message_react(new_channel_and_user['token'], message['message_id'], 1) with pytest.raises(InputError): message_unreact(new_channel_and_user['token'], message['message_id'], 0)
def test_message_react_user_not_in_channel(new_channel_and_user, new_channel_and_user_2): """ Test that if a user try to react a message when he/she is not in that channel""" message = message_send(new_channel_and_user['token'], new_channel_and_user['channel_id'], 'adcd') with pytest.raises(InputError): message_react(new_channel_and_user_2['token'], message['message_id'], 1)
def test_message_unreact_norm(new_channel_and_user): """ Test that a legal user unreat a peice of mesage when there is only one piece of message""" message = message_send(new_channel_and_user['token'], new_channel_and_user['channel_id'], 'adcd') message_react(new_channel_and_user['token'], message['message_id'], 1) message_unreact(new_channel_and_user['token'], message['message_id'], 1) message_specific = get_message_by_msg_id(message['message_id']) assert message_specific['reacts'] == [{ 'is_this_user_reacted': True, 'react_id': 1, 'u_ids': [] }]
def test_message_unreact_ueser_not_react(new_channel_and_user, new_channel_and_user_2): """ Test that if a uer try to unreact a message which is not his/her reaction""" message = message_send(new_channel_and_user['token'], new_channel_and_user['channel_id'], 'adcd') message_react(new_channel_and_user['token'], message['message_id'], 1) channel_invite(new_channel_and_user['token'], new_channel_and_user['channel_id'], new_channel_and_user_2['u_id']) with pytest.raises(InputError): message_unreact(new_channel_and_user_2['token'], message['message_id'], 1)
def test_message_react_normal(new_channel_and_user): """ Test that an legal user react a message""" message = message_send(new_channel_and_user['token'], new_channel_and_user['channel_id'], 'adcd') message_react(new_channel_and_user['token'], message['message_id'], 1) message_specific = get_message_by_msg_id(message['message_id']) assert message_specific['reacts'] == [{ 'react_id': 1, 'u_ids': [new_channel_and_user['u_id']], 'is_this_user_reacted': True }]
def message_react_wsgi(): json = request.get_json() return jsonify( message_react(json['token'], int(json['message_id']), json['react_id']))
def test_message_invalid_react_id(new_channel_and_user): """ Test that if a user try to react a message with an invalid react_id""" message = message_send(new_channel_and_user['token'], new_channel_and_user['channel_id'], 'adcd') with pytest.raises(InputError): message_react(new_channel_and_user['token'], message['message_id'], 0)