def test_get_contact_msgs(self):
        """Test getting contact's msgs"""

        contact_msgs = sentiment_analysis.get_contacts_msgs(7)

        self.assertEqual(contact_msgs[14][0].message_text,
                         u'This is an english test message')
Ejemplo n.º 2
0
def contact_messages_data(user_id):
    """Return contact's messages data."""

    if 'user_id' not in session:
        return redirect("/")
    elif session['user_id'] != user_id:
        return redirect("/users/%s" % session['user_id'])

    contact_msgs = sentiment_analysis.get_contacts_msgs(user_id)
    sentiment_list = sentiment_analysis.get_contacts(contact_msgs)
    arranged_list = sentiment_analysis.break_list(sentiment_list)
    print arranged_list

    data_dict = {
        "labels": arranged_list[0],
        "datasets": [
            {
                "label": "Positive messages",
                "fillColor": "#F7464A",
                "strokeColor": "rgba(220,220,220,0.8)",
                "highlightFill": "rgba(151,187,205,0.75)",
                "highlightStroke": "rgba(220,220,220,1)",
                "data": arranged_list[1]
            },
            {
                "label": "Negative messages",
                "fillColor": "#46BFBD",
                "strokeColor": "rgba(151,187,205,0.8)",
                "highlightFill": "rgba(151,187,205,0.75)",
                "highlightStroke": "#46BFBD",
                "data": arranged_list[2]
            },
            {
                "label": "Neutral messages",
                "fillColor": "#FDB45C",
                "strokeColor": "rgba(151,187,205,0.8)",
                "highlightFill": "rgba(151,187,205,0.75)",
                "highlightStroke": "#C0C0C0",
                "data": arranged_list[3]
            }
        ]
    };
    return jsonify(data_dict)
Ejemplo n.º 3
0
    def test_get_contact_msgs(self):
        """Test getting contact's msgs"""

        contact_msgs = sentiment_analysis.get_contacts_msgs(7)

        self.assertEqual(contact_msgs[14][0].message_text, u"This is an english test message")