예제 #1
0
    def testMarkRead2 (self):
        # comment1
        #     comment2
        #         comment3
        # comment4

        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)

        comment1.markCommentsAsRead()

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

        self.assertFalse (comment1.hasNew)
        self.assertFalse (comment2.hasNew)
        self.assertFalse (comment3.hasNew)
        self.assertFalse (comment4.hasNew)
예제 #2
0
    def testFindComment (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, post)

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

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

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

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

        post.addComments (tree)

        self.assertEqual (post.getComment (900), None)
        self.assertEqual (post.getComment (1000), comment1)
        self.assertEqual (post.getComment (1001), comment2)
        self.assertEqual (post.getComment (1002), comment3)
        self.assertEqual (post.getComment (1003), comment4)

        self.assertEqual (comment1.getComment (1001), comment2)
        self.assertEqual (comment1.getComment (1002), comment3)
        self.assertEqual (comment1.getComment (1003), None)