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)
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'))
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'))