def test_get_messages(self): """Test if you get messages""" messages = sentiment_analysis.get_messages(3) self.assertEqual(messages[0].message_text, "This is a russian test message") self.assertEqual(messages[0].user_id, 3) self.assertEqual(messages[0].original_lang_id, 5)
def test_get_messages(self): """Test if you get messages""" messages = sentiment_analysis.get_messages(3) self.assertEqual(messages[0].message_text, 'This is a russian test message') self.assertEqual(messages[0].user_id, 3) self.assertEqual(messages[0].original_lang_id, 5)
def messages_types_data(user_id): """Return data about messages emotions.""" if 'user_id' not in session: return redirect("/") elif session['user_id'] != user_id: return redirect("/users/%s" % session['user_id']) messages = sentiment_analysis.get_messages(user_id) sentiment_list = sentiment_analysis.analyze_messages(messages) arranged_list = sentiment_analysis.categorize_messages(sentiment_list) data_list_of_dicts = { 'arranged_list': [ { "value": arranged_list[0], "color": "#F7464A", "highlight": "#FF5A5E", "label": "Positive messages" }, { "value": arranged_list[1], "color": "#46BFBD", "highlight": "#5AD3D1", "label": "Negative messages" }, { "value": arranged_list[2], "color": "#FDB45C", "highlight": "#FFC870", "label": "Neutral messages" } ] } return jsonify(data_list_of_dicts)