Esempio n. 1
0
    def testMarkRead1 (self):
        # comment1
        #     comment2
        #         comment3
        # comment4

        postauthor = LJUser ('postauthor', 'http://example.com/image-jenyay-test.jpg')
        post = Post (postauthor, u'Это пост в ЖЖ', u'Заголовок', 123)

        user1 = LJUser ('jenyay-test', 'http://example.com/image-jenyay-test.jpg')
        comment1 = Comment (user1, u'Бла-бла-бла', 1000, 0)

        user2 = LJUser ('jenyay', 'http://example.com/image-jenyay.jpg')
        comment2 = Comment (user2, u'Ответ на коммент', 1001, 1000)

        user3 = LJUser ('username3', 'http://example.com/image-username3.jpg')
        comment3 = Comment (user3, u'Ответ на еще один коммент', 1002, 1001)

        user4 = LJUser ('username4', 'http://example.com/image-username4.jpg')
        comment4 = Comment (user4, u'Ответ на пост', 1003, 0)

        commentsFlat = [comment1, comment2, comment3, comment4]
        tree = buildTree (commentsFlat)

        post.addComments (tree)
        post.markCommentsAsRead ()

        self.assertFalse (comment1.isNew)
        self.assertFalse (comment2.isNew)
        self.assertFalse (comment3.isNew)
        self.assertFalse (comment4.isNew)

        self.assertFalse (comment1.hasNew)
        self.assertFalse (comment2.hasNew)
        self.assertFalse (comment3.hasNew)
        self.assertFalse (comment4.hasNew)

        self.assertEqual (comment1.post, None)
        self.assertEqual (comment2.post, None)
        self.assertEqual (comment3.post, None)
        self.assertEqual (comment4.post, None)