예제 #1
0
    def test_saving_comment_activity(self):
        """
            Test saving comment activity
        """
        self.initialize()

        # set up post for commenting
        post = Post()
        post.title = "Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u1
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film)
        post.save()

        comment = ThreadedComment()
        comment.user = self.u1
        comment.comment = "Lorem ipsum"
        comment.content_object = post
        comment.status = Object.PUBLIC_STATUS
        comment.type = Object.TYPE_COMMENT
        comment.permalink = "COMMENT"
        comment.save()

        activity = UserActivity.objects.get(comment=comment)

        # testing if activity was saved properly
        self.failUnlessEqual(activity.title,
                             comment.content_object.get_comment_title())
        self.failUnlessEqual(activity.content, comment.comment)
        if settings.ENSURE_OLD_STYLE_PERMALINKS:
            self.failUnlessEqual(
                activity.permalink,
                comment.content_object.get_absolute_url_old_style() + "#" +
                str(comment.id))
        else:
            self.failUnlessEqual(
                activity.permalink,
                comment.content_object.get_absolute_url() + "#" +
                str(comment.id))
        self.failUnlessEqual(activity.status, comment.status)
        self.failUnlessEqual(activity.activity_type, UserActivity.TYPE_COMMENT)
        self.failUnlessEqual(activity.username, self.u1.username)

        #planet_tag_helper without tag = 1 comment
        pth = PlanetTagHelper()
        comments = pth.planet_tag_comments()
        self.assertEquals(len(comments), 1)

        #planet_tag_helper with tag 'comedy' = 0 comment
        #no assigned films to comment
        pth_tags = PlanetTagHelper(tag='comedy')
        comments = pth_tags.planet_tag_comments()
        self.assertEquals(len(comments), 0)
예제 #2
0
    def test_saving_comment_activity(self):
        """
            Test saving comment activity
        """
        self.initialize()

        # set up post for commenting
        post = Post()
        post.title = "Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u1
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film)
        post.save()

        comment = ThreadedComment()
        comment.user = self.u1
        comment.comment = "Lorem ipsum"
        comment.content_object = post
        comment.status = Object.PUBLIC_STATUS
        comment.type = Object.TYPE_COMMENT
        comment.permalink = "COMMENT"
        comment.save()

        activity = UserActivity.objects.get(comment=comment)

        # testing if activity was saved properly
        self.failUnlessEqual(activity.title, comment.content_object.get_comment_title())
        self.failUnlessEqual(activity.content, comment.comment)
        if settings.ENSURE_OLD_STYLE_PERMALINKS:
            self.failUnlessEqual(
                activity.permalink, comment.content_object.get_absolute_url_old_style() + "#" + str(comment.id)
            )
        else:
            self.failUnlessEqual(activity.permalink, comment.content_object.get_absolute_url() + "#" + str(comment.id))
        self.failUnlessEqual(activity.status, comment.status)
        self.failUnlessEqual(activity.activity_type, UserActivity.TYPE_COMMENT)
        self.failUnlessEqual(activity.username, self.u1.username)

        # planet_tag_helper without tag = 1 comment
        pth = PlanetTagHelper()
        comments = pth.planet_tag_comments()
        self.assertEquals(len(comments), 1)

        # planet_tag_helper with tag 'comedy' = 0 comment
        # no assigned films to comment
        pth_tags = PlanetTagHelper(tag="comedy")
        comments = pth_tags.planet_tag_comments()
        self.assertEquals(len(comments), 0)
예제 #3
0
    def test_updating_comment_activity(self):
        """
            Test updating comment activity
        """

        self.initialize()

        # set up post for commenting
        post = Post()
        post.title = "Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u1
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film)
        post.save()

        comment = ThreadedComment()
        comment.user = self.u1
        comment.comment = "Lorem ipsum"
        comment.content_object = post
        comment.status = Object.PUBLIC_STATUS
        comment.type=Object.TYPE_COMMENT
        comment.permalink="COMMENT"
        comment.save()

        comment.comment = "siala lala tralala"
        comment.status = Object.DELETED_STATUS
        comment.save()
        activity = UserActivity.objects.get(comment=comment)

        # testing if activity was updated properly
        self.failUnlessEqual(activity.title, comment.content_object.get_comment_title())
        self.failUnlessEqual(activity.content, "siala lala tralala")
        if settings.ENSURE_OLD_STYLE_PERMALINKS:
            self.failUnlessEqual(activity.permalink, comment.content_object.get_absolute_url_old_style()+"#"+ str(comment.id))
        else:
            self.failUnlessEqual(activity.permalink, comment.content_object.get_absolute_url()+"#"+ str(comment.id))
        self.failUnlessEqual(activity.status, UserActivity.DELETED_STATUS)
        self.failUnlessEqual(activity.activity_type, UserActivity.TYPE_COMMENT)
        self.failUnlessEqual(activity.username, self.u1.username)
예제 #4
0
    def test_updating_comment_activity(self):
        """
            Test updating comment activity
        """

        self.initialize()

        # set up post for commenting
        post = Post()
        post.title = "Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u1
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film)
        post.save()

        comment = ThreadedComment()
        comment.user = self.u1
        comment.comment = "Lorem ipsum"
        comment.content_object = post
        comment.status = Object.PUBLIC_STATUS
        comment.type = Object.TYPE_COMMENT
        comment.permalink = "COMMENT"
        comment.save()

        comment.comment = "siala lala tralala"
        comment.status = Object.DELETED_STATUS
        comment.save()
        activity = UserActivity.objects.get(comment=comment)

        # testing if activity was updated properly
        self.failUnlessEqual(activity.title,
                             comment.content_object.get_comment_title())
        self.failUnlessEqual(activity.content, "siala lala tralala")
        if settings.ENSURE_OLD_STYLE_PERMALINKS:
            self.failUnlessEqual(
                activity.permalink,
                comment.content_object.get_absolute_url_old_style() + "#" +
                str(comment.id))
        else:
            self.failUnlessEqual(
                activity.permalink,
                comment.content_object.get_absolute_url() + "#" +
                str(comment.id))
        self.failUnlessEqual(activity.status, UserActivity.DELETED_STATUS)
        self.failUnlessEqual(activity.activity_type, UserActivity.TYPE_COMMENT)
        self.failUnlessEqual(activity.username, self.u1.username)