Exemple #1
0
 def test_create_with_template(self, render):
     page.create('with-template', template='the_template.rst')
     render.assert_called_once_with(
         'the_template.rst',
         mock.ANY,
         mock.ANY,
     )
Exemple #2
0
def build_theme(use_theme):
    # setup blog
    setup()

    # write conf file with given theme
    writer.write_conf_file(theme=use_theme)

    # load content
    lorem = load_content()

    # create posts
    post.create("This is a post",
                datetime.date(2010, 10, 1)).write(tags="tag #1, tag #2",
                                                  content=lorem)
    post.create("This is another post", datetime.date(2010, 11,
                                                      2)).write(tags="tag #1",
                                                                content=lorem)
    post.create("This is yet another post",
                datetime.date(2010, 12, 3)).write(tags="tag #2", content=lorem)

    # create pages
    page.create("First page").write()
    page.create("Second page").write()

    # build
    cmdline.build()
Exemple #3
0
    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")))
Exemple #4
0
 def test_create_with_template(self, render):
     page.create('with-template', template='the_template.rst')
     render.assert_called_once_with(
         'the_template.rst',
         mock.ANY,
         mock.ANY,
     )
Exemple #5
0
    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")))
Exemple #6
0
 def test_create_without_template(self, render):
     page.create('no-template')
     render.assert_called_once_with(
         paths.page_template,
         mock.ANY,
         mock.ANY,
     )
Exemple #7
0
 def test_create_without_template(self, render):
     page.create('no-template')
     render.assert_called_once_with(
         paths.page_template,
         mock.ANY,
         mock.ANY,
     )
Exemple #8
0
def build_theme(use_theme):
    # setup blog
    setup()

    # write conf file with given theme
    writer.write_conf_file(theme=use_theme)

    # load content
    lorem = load_content()

    # create posts
    post.create("This is a post", datetime.date(2010, 10, 1)).write(
            tags="tag #1, tag #2",
            content=lorem)
    post.create("This is another post", datetime.date(2010, 11, 2)).write(
            tags="tag #1",
            content=lorem)
    post.create("This is yet another post", datetime.date(2010, 12, 3)).write(
            tags="tag #2",
            content=lorem)

    # create pages
    page.create("First page").write()
    page.create("Second page").write()

    # build
    cmdline.build()
Exemple #9
0
    def test_master_update(self):
        page.create("Page 1")
        page.create("Page 2")

        with open(tinkerer.paths.master_file, "r") as f:
            lines = f.readlines()

            self.assertEquals("   pages/page_1\n", lines[-3])
            self.assertEquals("   pages/page_2\n", lines[-2])
Exemple #10
0
    def test_master_update(self):
        page.create("Page 1")
        page.create("Page 2")

        with open(tinkerer.paths.master_file, "r") as f:
            lines = f.readlines()

            self.assertEquals("   pages/page_1\n", lines[-3])
            self.assertEquals("   pages/page_2\n", lines[-2])
Exemple #11
0
    def test_ordering(self):
        utils.test = self

        # create some pages and posts
        page.create("First Page")
        post.create("Oldest Post", datetime.date(2010, 10, 1))
        post.create("Newer Post", datetime.date(2010, 10, 1))
        page.create("Another Page")
        post.create("Newest Post", datetime.date(2010, 10, 1))

        utils.hook_extension("test_ordering")
        self.build()
Exemple #12
0
    def test_ordering(self):
        utils.test = self

        # create some pages and posts
        page.create("First Page")
        post.create("Oldest Post", datetime.date(2010, 10, 1))
        post.create("Newer Post", datetime.date(2010, 10, 1))
        page.create("Another Page")
        post.create("Newest Post", datetime.date(2010, 10, 1))

        utils.hook_extension("test_ordering")
        self.build()
Exemple #13
0
    def test_metadata(self):
        utils.test = self

        # create some posts
        for i in range(20):
            post.create("Post %d" % i, datetime.date(2010, 10, i + 1)).write(content=" ".join("a" * 100))

        # ... and some pages
        for i in range(10):
            page.create("Page %d" % i)

        utils.hook_extension("test_metadata")
        self.build()
Exemple #14
0
    def test_metadata(self):
        utils.test = self

        # create some posts
        for i in range(20):
            post.create("Post %d" % i, datetime.date(
                2010, 10, i + 1)).write(content=" ".join("a" * 100))

        # ... and some pages
        for i in range(10):
            page.create("Page %d" % i)

        utils.hook_extension("test_metadata")
        self.build()
Exemple #15
0
    def test_move(self):
        # create a post and a page
        new_post = post.create("A post", datetime.datetime(2010, 10, 1))
        new_page = page.create("A page")

        # page and posts should be in master doc (precondition)
        lines = master.read_master()
        self.assertTrue("   %s\n" % new_post.docname in lines)
        self.assertTrue("   %s\n" % new_page.docname in lines)

        new_draft = draft.move(os.path.join(utils.TEST_ROOT, "pages", "a_page.rst"))
        self.assertTrue(os.path.exists(new_draft))

        # page should no longer be in TOC
        lines = master.read_master()
        self.assertTrue("   %s\n" % new_post.docname in lines)
        self.assertFalse("   %s\n" % new_page.docname in lines)

        new_draft = draft.move(os.path.join(utils.TEST_ROOT, "2010", "10", "01", "a_post.rst"))
        self.assertTrue(os.path.exists(new_draft))

        # post should no longer be in TOC either
        lines = master.read_master()
        self.assertFalse("   %s\n" % new_post.docname in lines)
        self.assertFalse("   %s\n" % new_page.docname in lines)
Exemple #16
0
    def test_move(self):
        # create a post and a page
        new_post = post.create("A post", datetime.datetime(2010, 10, 1))
        new_page = page.create("A page")

        # page and posts should be in master doc (precondition)
        lines = master.read_master()
        self.assertTrue("   %s\n" % new_post.docname in lines)
        self.assertTrue("   %s\n" % new_page.docname in lines)

        new_draft = draft.move(
            os.path.join(utils.TEST_ROOT, "pages", "a_page.rst"))
        self.assertTrue(os.path.exists(new_draft))

        # page should no longer be in TOC
        lines = master.read_master()
        self.assertTrue("   %s\n" % new_post.docname in lines)
        self.assertFalse("   %s\n" % new_page.docname in lines)

        new_draft = draft.move(
            os.path.join(utils.TEST_ROOT, "2010", "10", "01", "a_post.rst"))
        self.assertTrue(os.path.exists(new_draft))

        # post should no longer be in TOC either
        lines = master.read_master()
        self.assertFalse("   %s\n" % new_post.docname in lines)
        self.assertFalse("   %s\n" % new_page.docname in lines)
Exemple #17
0
    def test_content(self):
        new_page = page.create("My Page")

        # check expected empty page content
        with open(new_page.path) as f:
            self.assertEquals(f.readlines(),
                    ["My Page\n",
                     "=======\n",
                     "\n"])
Exemple #18
0
    def test_content(self):
        new_page = page.create("My Page")

        # check expected empty page content
        with open(new_page.path) as f:
            self.assertEquals(f.readlines(),
                    ["My Page\n",
                     "=======\n",
                     "\n"])
Exemple #19
0
    def test_nolandingpage(self):
        # 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 not redirect to landing page
        self.assertFalse(
            '<meta http-equiv="REFRESH" content="0; url=./pages/%s.html" />' %
            LANDING_PAGE in self.__get_index_text())

        # there should be no page1.html aggregated page
        self.assertFalse(
            os.path.exists(
                os.path.join(utils.TEST_ROOT, "blog", "html", "page1.html")))
Exemple #20
0
    def test_create(self):
        # create page
        new_page = page.create("My Page")

        self.assertEquals(
            os.path.abspath(
                os.path.join(utils.TEST_ROOT, "pages", "my_page.rst")),
            new_page.path)

        self.assertTrue(os.path.exists(new_page.path))
        self.assertEquals("pages/my_page", new_page.docname)
Exemple #21
0
    def test_nolandingpage(self):
        # 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 not redirect to landing page
        self.assertFalse(
            '<meta http-equiv="REFRESH" content="0; url=./pages/%s.html" />'
            % LANDING_PAGE in self.__get_index_text())

        # there should be no page1.html aggregated page
        self.assertFalse(
            os.path.exists(os.path.join(
                utils.TEST_ROOT,
                "blog",
                "html",
                "page1.html")))
Exemple #22
0
    def test_create(self):
        # create page
        new_page = page.create("My Page")

        self.assertEquals(
            os.path.abspath(os.path.join(
                utils.TEST_ROOT,
                "pages",
                "my_page.rst")),
            new_page.path)

        self.assertTrue(os.path.exists(new_page.path))
        self.assertEquals("pages/my_page", new_page.docname)
Exemple #23
0
def create_page(title, template):
    '''
    Creates a new page with the given title or makes an existing file a page.
    '''
    move = os.path.exists(title)

    if move:
        new_page = page.move(title)
    else:
        new_page = page.create(title, template)

    output.filename.info(new_page.path)
    if move:
        output.write.info("Draft moved to page '%s'" % new_page.path)
    else:
        output.write.info("New page created as '%s'" % new_page.path)
Exemple #24
0
def create_page(title, template):
    '''
    Creates a new page with the given title or makes an existing file a page.
    '''
    move = os.path.exists(title)

    if move:
        new_page = page.move(title)
    else:
        new_page = page.create(title, template)

    output.filename.info(new_page.path)
    if move:
        output.write.info("Draft moved to page '%s'" % new_page.path)
    else:
        output.write.info("New page created as '%s'" % new_page.path)
Exemple #25
0
    def test_create_duplicate(self):
        # create initial post
        page.create("Page1")

        # should raise
        page.create("Page1")
Exemple #26
0
    def test_move_duplicate(self):
        # create initial page
        page.create("Page1")

        # should raise
        page.move("Page1")
Exemple #27
0
    def test_move_duplicate(self):
        # create initial page
        page.create("Page1")

        # should raise
        page.move("Page1")
Exemple #28
0
    def test_create_duplicate(self):
        # create initial post
        page.create("Page1")

        # should raise
        page.create("Page1")