Пример #1
0
    def test_comments(self):
        """ Tests the insertion and deletion of comments """

        bat = queries.find_media_by_creator('Dario')
        queries.insert_comment(bat[0].media_id, 11, 7, 0.9, 0.4, -0.5, 0.6, 0.3)
        comments = queries.find_comments_for_media(bat[0].media_id)

        # can we find the comments?
        self.assertEqual(comments[0].item_id, bat[0].media_id, \
                    'Retrieved incorrect id')
        self.assertEqual(comments[0].relevancy, 7, \
                    msg='Retrieved incorrect relevancy')
        self.assertAlmostEqual(float(comments[0].pleasantness), 0.9, \
                    msg='Retrieved incorrect pleasantness')
        self.assertAlmostEqual(float(comments[0].attention), 0.4, \
                    msg='Retrieved incorrect attention')
        self.assertAlmostEqual(float(comments[0].sensitivity), -0.5, \
                    msg='Retrieved incorrect sensitivity')
        self.assertAlmostEqual(float(comments[0].aptitude), 0.6, \
                    msg='Retrieved incorrect aptitude')
        self.assertAlmostEqual(float(comments[0].polarity), 0.3, \
                    msg='Retrieved incorrect polarity')

        # is the number of comments incremented
        bat = queries.find_media_by_creator('Dario')

        self.assertEqual(bat[0].number_of_comments, 1, 
                        'Retrieved incorrect number of comments')
Пример #2
0
    def test_clean(self):
        """ Tests cleaning the database of comments and emotions """

        bat = queries.find_media_by_asin('0440419395')
        queries.insert_comment(bat.media_id, 11, 7, 0.9, 0.4, -0.5, 0.6, 0.3)

        queries.clean_media(bat.media_id)

        comments = queries.find_comments_for_media(bat.media_id)
        emotions = queries.find_emotions_for_media(bat.media_id)

        self.assertEqual(len(comments), 0)
        self.assertEqual(len(emotions), 0)