def test_disqus(self): TEST_SHORTNAME = "test_shortname" # add disqus_shortname in conf.py utils.update_conf( {"disqus_shortname = None": 'disqus_shortname = "%s"' % TEST_SHORTNAME}) # create a post post.create("post1", datetime.date(2010, 10, 1)) POST_ID = "2010/10/01/post1" POST_LINK = "http://127.0.0.1/blog/html/" + POST_ID + ".html" # build blog self.build() # ensure disqus script is added to html output output = os.path.join(utils.TEST_ROOT, "blog", "html", "2010", "10", "01", "post1.html") output_html = open(output, "r").read() self.assertTrue( disqus.create_thread(TEST_SHORTNAME, POST_ID) in output_html) output = os.path.join(utils.TEST_ROOT, "blog", "html", "index.html") output_html = open(output, "r").read() # ensure script to enable comment count is added to aggregated page self.assertTrue( disqus.enable_count(TEST_SHORTNAME) in output_html) # ensure comment count is added to aggregated page self.assertTrue( disqus.get_count(POST_LINK, POST_ID) in output_html)
def test_disqus(self): TEST_SHORTNAME = "test_shortname" # add disqus_shortname in conf.py utils.update_conf({ "disqus_shortname = None": 'disqus_shortname = "%s"' % TEST_SHORTNAME }) # create a post post.create("post1", datetime.date(2010, 10, 1)) POST_ID = "2010/10/01/post1" POST_LINK = "http://127.0.0.1/blog/html/" + POST_ID + ".html" # build blog self.build() # ensure disqus script is added to html output output = os.path.join(utils.TEST_ROOT, "blog", "html", "2010", "10", "01", "post1.html") output_html = open(output, "r").read() self.assertTrue( disqus.create_thread(TEST_SHORTNAME, POST_ID) in output_html) output = os.path.join(utils.TEST_ROOT, "blog", "html", "index.html") output_html = open(output, "r").read() # ensure script to enable comment count is added to aggregated page self.assertTrue(disqus.enable_count(TEST_SHORTNAME) in output_html) # ensure comment count is added to aggregated page self.assertTrue(disqus.get_count(POST_LINK, POST_ID) in output_html)
def test_landingpage(self): # set landing_page option in conf.py utils.update_conf( {"landing_page = None": 'landing_page = "%s"' % LANDING_PAGE}) # create some posts for new_post in [("Post1", "Post2", "Post3")]: post.create(new_post[0]).write() # create the landing page page.create(LANDING_PAGE) self.build() # index.html should redirect to landing page self.assertTrue( '<meta http-equiv="REFRESH" content="0; url=./pages/%s.html" />' % LANDING_PAGE in self.__get_index_text()) # there should be page1.html aggregated page self.assertTrue( os.path.exists(os.path.join( utils.TEST_ROOT, "blog", "html", "page1.html")))
def test_missing(self): # set landing_page option in conf.py utils.update_conf( {"landing_page = None": 'landing_page = "%s"' % LANDING_PAGE}) # create some posts for new_post in [("Post1", "Post2", "Post3")]: post.create(new_post[0]).write() # hide Sphinx stderr output for the extension exception with mock.patch.object(sys, "stderr"): # build should fail self.build(expected_return=1)
def test_firstpagetitle(self): utils.update_conf({ "first_page_title = None": 'first_page_title = "%s"' % FIRST_PAGE_TITLE }) # create a post post.create("Post1").write() self.build() index_path = os.path.join(utils.TEST_ROOT, "blog", "html", "index.html") index_text = open(index_path, "r").read() # index.html should contain the title self.assertTrue('<a href="#">%s</a>' % FIRST_PAGE_TITLE in index_text)
def test_firstpagetitle(self): utils.update_conf( {"first_page_title = None": 'first_page_title = "%s"' % FIRST_PAGE_TITLE}) # create a post post.create("Post1").write() self.build() index_path = os.path.join(utils.TEST_ROOT, "blog", "html", "index.html") index_text = open(index_path, "r").read() # index.html should contain the title self.assertTrue( '<a href="#">%s</a>' % FIRST_PAGE_TITLE in index_text)