Esempio n. 1
0
    def testPostHtml (self):
        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)

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

        post.addComments (tree)

        generator = HtmlGenerator (self.templatePath, post)

        html = generator.makePostHtml ()
        self._commentInText (comment1, html, generator.indent * 0)
        self._commentInText (comment2, html, generator.indent * 1)
        self._commentInText (comment3, html, generator.indent * 2)
        self._commentInText (comment4, html, generator.indent * 0)

        self._contentInText (post, html)
Esempio n. 2
0
    def testPostBodyHtml (self):
        postauthor = LJUser ('postauthor', 'http://example.com/image-jenyay-test.jpg')
        post = Post (postauthor, u'Это пост в ЖЖ', u'Заголовок', 123)

        generator = HtmlGenerator (self.templatePath, post)
        html = generator.makePostBodyHtml ()
        self._contentInText (post, html)
Esempio n. 3
0
    def testCommentHtml (self):
        username = '******'
        userpic = 'http://example.com/image.jpg'

        body = u'Бла-бла-бла'
        dtalkid = 1234
        parentdtalkid = 6543

        user = LJUser (username, userpic)
        comment = Comment (user, body, dtalkid, parentdtalkid)

        generator = HtmlGenerator (self.templatePath, [comment])
        text = generator.makeCommentHtml (comment)

        self._commentInText (comment, text, 0)
Esempio n. 4
0
    def testNavalnyPost (self):
        # http://navalny.livejournal.com/762032.html?style=mine
        username = "******"
        postid = 762032

        loader = PostLoader (testparams.ljusername, testparams.ljpassword)

        post = loader.getPost (LJUrl (username, postid) )
        generator = HtmlGenerator (self.templatePath, post)
        html = generator.makePostHtml ()

        self._contentInText (post, html)
        self.assertTrue (u'Комментариев: 3245' in html)

        with open ('../temp/testNavalnyPost.htm', 'w') as fp:
            fp.write (html.encode ('utf8'))
Esempio n. 5
0
    def testRealPost1 (self):
        # http://jenyay.livejournal.com/244224.html?style=mine
        username = "******"
        postid = 244224

        loader = PostLoader (testparams.ljusername, testparams.ljpassword)

        post = loader.getPost (LJUrl (username, postid) )
        generator = HtmlGenerator (self.templatePath, post)
        html = generator.makePostHtml ()

        self._contentInText (post, html)
        self.assertTrue (u'Комментариев: 37' in html)
        self.assertTrue (u'О двойных стандартах' in html)
        self.assertTrue (u'Архивируем rar-ом под Виндой файлы' in html)
        self.assertTrue (u'Винда - стандарт.' in html)
        self.assertTrue (u'Не, если программа не поддерживает работу с Unicode, то это опять же виновата программа.' in html)

        with open ('../temp/testRealPost1.htm', 'w') as fp:
            fp.write (html.encode ('utf8'))
Esempio n. 6
0
    def testCommentsTreeHtml (self):
        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)
        generator = HtmlGenerator (self.templatePath, tree)

        html = generator.makeCommentsTreeHtml ()
        self._commentInText (comment1, html, generator.indent * 0)
        self._commentInText (comment2, html, generator.indent * 1)
        self._commentInText (comment3, html, generator.indent * 2)
        self._commentInText (comment4, html, generator.indent * 0)