def test_successful_react(): # successful thumb up user1 = user_from_token(token1) msg_id4 = data['channels'][0].messages[3].message_id assert msg_react(token1, msg_id4, 1) == {} assert data['channels'][0].messages[3].reactions[0].react_id == 1 assert data['channels'][0].messages[3].reactions[ 0].reacter == user_from_token(token1).u_id assert user1.reacted_msgs[0] == msg_id4
def route_msg_react(): token = request.form.get('token') msg_id = int(request.form.get('message_id')) react_id = int(request.form.get('react_id')) return dumps(msg_react(token, msg_id, react_id))
def test_react_msgid_notvalid(): # when the message_id is not valid with pytest.raises(ValueError): msg_react(token1, 6666, 1)
def test_reactid_notvalid(): # when not passing in 1 as react id msg_id3 = data['channels'][0].messages[2].message_id with pytest.raises(ValueError): msg_react(token1, msg_id3, 2)
def test_reacted(): # when the message is already reacted msg_id4 = data['channels'][0].messages[3].message_id with pytest.raises(ValueError): msg_react(token1, msg_id4, 1)