Exemple #1
0
    def test_add_and_remove_shout(self):
        # commenter1 posts a shout on owner's page
        c1 = shout.insert(self.commenter1, orm.Comment(userid=self.owner,
                                                       content="hello"))
        self.assertEqual(1, self.count_notifications(self.owner))

        # commenter2 posts a reply to c1
        c2 = shout.insert(self.commenter2, orm.Comment(userid=self.owner,
                                                       content="hello", parentid=c1))
        self.assertEqual(1, self.count_notifications(self.commenter1))

        # owner posts a reply to c2
        c3 = shout.insert(self.owner, orm.Comment(userid=self.owner,
                                                  content="hello", parentid=c2))
        self.assertEqual(1, self.count_notifications(self.commenter2))

        # commenter1 responds to owner
        shout.insert(self.commenter1, orm.Comment(userid=self.owner,
                                                  content="hello", parentid=c3))
        self.assertEqual(2, self.count_notifications(self.owner))

        # owner deletes comment thread
        shout.remove(self.owner, commentid=c1)
        self.assertEqual(0, self.count_notifications(self.owner))
        self.assertEqual(0, self.count_notifications(self.commenter1))
        self.assertEqual(0, self.count_notifications(self.commenter2))
Exemple #2
0
def remove_comment_(request):
    form = request.web_input(commentid="", feature="", format="")
    commentid = define.get_int(form.commentid)

    if form.feature == "userid":
        targetid = shout.remove(request.userid, commentid=commentid)
    else:
        targetid = comment.remove(request.userid, commentid=commentid, feature=form.feature)

    if form.format == "json":
        return {"success": True}

    if form.feature == "userid":
        raise HTTPSeeOther(location="/shouts?userid=%i" % (targetid,))
    elif form.feature == "submit":
        raise HTTPSeeOther(location="/submission/%i" % (targetid,))
    elif form.feature == "char":
        raise HTTPSeeOther(location="/character/%i" % (targetid,))
    elif form.feature == "journal":
        raise HTTPSeeOther(location="/journal/%i" % (targetid,))
Exemple #3
0
    def POST(self):
        form = web.input(commentid="", feature="", format="")
        commentid = define.get_int(form.commentid)

        if form.feature == "userid":
            targetid = shout.remove(self.user_id, commentid=commentid)
        else:
            targetid = comment.remove(self.user_id, commentid=commentid, feature=form.feature)

        if form.format == "json":
            return {"success": True}

        if form.feature == "userid":
            raise web.seeother("/shouts?userid=%i" % (targetid,))
        elif form.feature == "submit":
            raise web.seeother("/submission/%i" % (targetid,))
        elif form.feature == "char":
            raise web.seeother("/character/%i" % (targetid,))
        elif form.feature == "journal":
            raise web.seeother("/journal/%i" % (targetid,))
Exemple #4
0
def remove_comment_(request):
    form = request.web_input(commentid="", feature="", format="")
    commentid = define.get_int(form.commentid)

    if form.feature == "userid":
        targetid = shout.remove(request.userid, commentid=commentid)
    else:
        targetid = comment.remove(request.userid, commentid=commentid, feature=form.feature)

    if form.format == "json":
        return {"success": True}

    if form.feature == "userid":
        raise HTTPSeeOther(location="/shouts?userid=%i" % (targetid,))
    elif form.feature == "submit":
        raise HTTPSeeOther(location="/submission/%i" % (targetid,))
    elif form.feature == "char":
        raise HTTPSeeOther(location="/character/%i" % (targetid,))
    elif form.feature == "journal":
        raise HTTPSeeOther(location="/journal/%i" % (targetid,))
Exemple #5
0
    def POST(self):
        form = web.input(commentid="", feature="", format="")
        commentid = define.get_int(form.commentid)

        if form.feature == "userid":
            targetid = shout.remove(self.user_id, commentid=commentid)
        else:
            targetid = comment.remove(self.user_id,
                                      commentid=commentid,
                                      feature=form.feature)

        if form.format == "json":
            return {"success": True}

        if form.feature == "userid":
            raise web.seeother("/shouts?userid=%i" % (targetid, ))
        elif form.feature == "submit":
            raise web.seeother("/submission/%i" % (targetid, ))
        elif form.feature == "char":
            raise web.seeother("/character/%i" % (targetid, ))
        elif form.feature == "journal":
            raise web.seeother("/journal/%i" % (targetid, ))
Exemple #6
0
    def test_add_and_remove_shout(self):
        # commenter1 posts a shout on owner's page
        c1 = shout.insert(self.commenter1,
                          target_user=self.owner,
                          parentid=None,
                          content="hello",
                          staffnotes=False)
        self.assertEqual(1, self.count_notifications(self.owner))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 1)
        self.assertTrue(
            shouts[0].viewitems() >= {"content": "hello"}.viewitems())

        # commenter2 posts a reply to c1
        c2 = shout.insert(self.commenter2,
                          target_user=self.owner,
                          parentid=c1,
                          content="reply",
                          staffnotes=False)
        self.assertEqual(1, self.count_notifications(self.commenter1))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 2)
        self.assertTrue(
            shouts[1].viewitems() >= {"content": "reply"}.viewitems())

        # owner posts a reply to c2
        c3 = shout.insert(self.owner,
                          target_user=self.owner,
                          parentid=c2,
                          content="reply 2",
                          staffnotes=False)
        self.assertEqual(1, self.count_notifications(self.commenter2))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 3)
        self.assertTrue(
            shouts[2].viewitems() >= {"content": "reply 2"}.viewitems())

        # commenter1 responds to owner
        shout.insert(self.commenter1,
                     target_user=self.owner,
                     parentid=c3,
                     content="reply 3",
                     staffnotes=False)
        self.assertEqual(2, self.count_notifications(self.owner))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 4)
        self.assertTrue(
            shouts[3].viewitems() >= {"content": "reply 3"}.viewitems())

        # commenter1 posts a new root shout
        shout.insert(self.commenter1,
                     target_user=self.owner,
                     parentid=None,
                     content="root 2",
                     staffnotes=False)
        self.assertEqual(3, self.count_notifications(self.owner))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 5)
        self.assertTrue(
            shouts[0].viewitems() >= {"content": "root 2"}.viewitems())
        self.assertTrue(
            shouts[4].viewitems() >= {"content": "reply 3"}.viewitems())

        # commenter2 posts another reply to c1
        shout.insert(self.commenter2,
                     target_user=self.owner,
                     parentid=c1,
                     content="reply 4",
                     staffnotes=False)
        self.assertEqual(2, self.count_notifications(self.commenter1))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 6)
        self.assertTrue(
            shouts[5].viewitems() >= {"content": "reply 4"}.viewitems())

        # owner deletes comment thread
        shout.remove(self.owner, commentid=c1)
        self.assertEqual(1, self.count_notifications(self.owner))
        self.assertEqual(0, self.count_notifications(self.commenter1))
        self.assertEqual(0, self.count_notifications(self.commenter2))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 1)
        self.assertTrue(
            shouts[0].viewitems() >= {"content": "root 2"}.viewitems())
Exemple #7
0
    def test_add_and_remove_shout(self):
        # commenter1 posts a shout on owner's page
        c1 = shout.insert(self.commenter1, orm.Comment(userid=self.owner,
                                                       content="hello"))
        self.assertEqual(1, self.count_notifications(self.owner))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 1)
        self.assertTrue(shouts[0].viewitems() >= {"content": "hello"}.viewitems())

        # commenter2 posts a reply to c1
        c2 = shout.insert(self.commenter2, orm.Comment(userid=self.owner,
                                                       content="reply", parentid=c1))
        self.assertEqual(1, self.count_notifications(self.commenter1))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 2)
        self.assertTrue(shouts[1].viewitems() >= {"content": "reply"}.viewitems())

        # owner posts a reply to c2
        c3 = shout.insert(self.owner, orm.Comment(userid=self.owner,
                                                  content="reply 2", parentid=c2))
        self.assertEqual(1, self.count_notifications(self.commenter2))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 3)
        self.assertTrue(shouts[2].viewitems() >= {"content": "reply 2"}.viewitems())

        # commenter1 responds to owner
        shout.insert(self.commenter1, orm.Comment(userid=self.owner,
                                                  content="reply 3", parentid=c3))
        self.assertEqual(2, self.count_notifications(self.owner))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 4)
        self.assertTrue(shouts[3].viewitems() >= {"content": "reply 3"}.viewitems())

        # commenter1 posts a new root shout
        shout.insert(self.commenter1, orm.Comment(userid=self.owner,
                                                  content="root 2"))
        self.assertEqual(3, self.count_notifications(self.owner))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 5)
        self.assertTrue(shouts[0].viewitems() >= {"content": "root 2"}.viewitems())
        self.assertTrue(shouts[4].viewitems() >= {"content": "reply 3"}.viewitems())

        # commenter2 posts another reply to c1
        shout.insert(self.commenter2, orm.Comment(userid=self.owner,
                                                  content="reply 4", parentid=c1))
        self.assertEqual(2, self.count_notifications(self.commenter1))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 6)
        self.assertTrue(shouts[5].viewitems() >= {"content": "reply 4"}.viewitems())

        # owner deletes comment thread
        shout.remove(self.owner, commentid=c1)
        self.assertEqual(1, self.count_notifications(self.owner))
        self.assertEqual(0, self.count_notifications(self.commenter1))
        self.assertEqual(0, self.count_notifications(self.commenter2))

        shouts = shout.select(0, self.owner)
        self.assertEqual(len(shouts), 1)
        self.assertTrue(shouts[0].viewitems() >= {"content": "root 2"}.viewitems())