Ejemplo n.º 1
0
    def test_draft(self):
        cmdline.main(["--draft", "My Draft", "--quiet"])

        file_path = os.path.join(utils.TEST_ROOT, "drafts", "my_draft.rst")

        # assert draft was created
        self.assertTrue(os.path.exists(file_path))
Ejemplo n.º 2
0
    def test_draft(self):
        cmdline.main(["--draft", "My Draft", "--quiet"])

        file_path = os.path.join(utils.TEST_ROOT, "drafts", "my_draft.rst")

        # assert draft was created
        self.assertTrue(os.path.exists(file_path))
Ejemplo n.º 3
0
    def test_post_with_date(self):
        cmdline.main(["--post", "Dated Post", "--date", "2011/11/20"])

        file_path = os.path.join(utils.TEST_ROOT, "2011/11/20", "dated_post.rst")

        # assert file exists
        self.assertTrue(os.path.exists(file_path))
Ejemplo n.º 4
0
    def test_page_from_title(self):
        cmdline.main(["--page", "My Test Page", "--quiet"])

        file_path = os.path.join(utils.TEST_ROOT, "pages", "my_test_page.rst")

        # assert file exsits
        self.assertTrue(os.path.exists(file_path))
Ejemplo n.º 5
0
    def test_page_from_title(self):
        cmdline.main(["--page", "My Test Page", "--quiet"])

        file_path = os.path.join(utils.TEST_ROOT, "pages", "my_test_page.rst")

        # assert file exsits
        self.assertTrue(os.path.exists(file_path))
Ejemplo n.º 6
0
    def test_post_with_date(self):
        cmdline.main(["--post", "Dated Post", "--date", "2011/11/20"])

        file_path = os.path.join(utils.TEST_ROOT, "2011/11/20",
                                 "dated_post.rst")

        # assert file exists
        self.assertTrue(os.path.exists(file_path))
Ejemplo n.º 7
0
    def test_date_only_on_post(self):
        self.assertNotEqual(
            0, cmdline.main(["--page", "Test Page", "--date", "2011/11/20"]))

        self.assertNotEqual(
            0, cmdline.main(["--draft", "Test Draft", "--date", "2011/11/20"]))

        self.assertNotEqual(0,
                            cmdline.main(["--build", "--date", "2011/11/20"]))
Ejemplo n.º 8
0
    def test_date_only_on_post(self):
        self.assertNotEqual(0,
                cmdline.main(["--page", "Test Page", "--date", "2011/11/20"]))

        self.assertNotEqual(0,
                cmdline.main(["--draft", "Test Draft", "--date", "2011/11/20"]))

        self.assertNotEqual(0,
                cmdline.main(["--build", "--date", "2011/11/20"]))
Ejemplo n.º 9
0
    def test_post_from_title(self):
        cmdline.main(["--post", "My Test Post", "--quiet"])

        # this might fail at midnight :P
        year, month, day = tinkerer.utils.split_date()

        file_path = os.path.join(utils.TEST_ROOT, year, month, day, "my_test_post.rst")

        # assert file exists
        self.assertTrue(os.path.exists(file_path))
Ejemplo n.º 10
0
    def test_setup(self):
        # blog is setup as part of test setup, tear it down and re-create it via
        # cmdline
        self.tearDown()
        cmdline.main(["--setup", "--quiet"])

        self.assertEqual(
            set(os.listdir(utils.TEST_ROOT)),
            set(["_static", "_templates", "drafts", "conf.py", "index.html", tinkerer.master_doc + ".rst"]),
        )
Ejemplo n.º 11
0
    def test_post_from_title(self):
        cmdline.main(["--post", "My Test Post", "--quiet"])

        # this might fail at midnight :P
        year, month, day = tinkerer.utils.split_date()

        file_path = os.path.join(utils.TEST_ROOT, year, month, day,
                                 "my_test_post.rst")

        # assert file exists
        self.assertTrue(os.path.exists(file_path))
Ejemplo n.º 12
0
    def test_setup(self):
        # blog is setup as part of test setup, tear it down and re-create it via
        # cmdline
        self.tearDown()
        cmdline.main(["--setup", "--quiet"])

        self.assertEqual(
            set(os.listdir(utils.TEST_ROOT)),
            set([
                "_static", "_templates", "drafts", "conf.py", "index.html",
                tinkerer.master_doc + ".rst"
            ]))
Ejemplo n.º 13
0
    def test_root_only(self):
        # remove "conf.py" created by test setup
        os.remove(os.path.join(paths.root, "conf.py"))

        self.assertNotEqual(0, cmdline.main(["--page", "Test Post", "--quiet"]))

        self.assertNotEqual(0, cmdline.main(["--post", "Test Page", "--quiet"]))

        self.assertNotEqual(0, cmdline.main(["--build", "--quiet"]))

        # setup should work fine from anywhere
        self.assertEqual(0, cmdline.main(["--setup", "--quiet"]))
Ejemplo n.º 14
0
    def test_filename_only(self):
        # hook up test log handler
        test_stream = StringIO()

        # restore logging for this particular test
        logging.disable(logging.NOTSET)

        output.filename.addHandler(logging.StreamHandler(test_stream))

        # setup new blog with --filename flag
        cmdline.main(["--setup", "--filename"])

        # output should be `conf.py`
        self.assertEquals("conf.py", test_stream.getvalue().strip())
Ejemplo n.º 15
0
    def test_filename_only(self):
        # hook up test log handler
        test_stream = StringIO()

        # restore logging for this particular test
        logging.disable(logging.NOTSET)

        output.filename.addHandler(logging.StreamHandler(test_stream))

        # setup new blog with --filename flag
        cmdline.main(["--setup", "--filename"])

        # output should be `conf.py`
        self.assertEquals("conf.py", test_stream.getvalue().strip())
Ejemplo n.º 16
0
    def test_root_only(self):
        # remove "conf.py" created by test setup
        os.remove(os.path.join(paths.root, "conf.py"))

        self.assertNotEqual(0, cmdline.main(["--page", "Test Post",
                                             "--quiet"]))

        self.assertNotEqual(0, cmdline.main(["--post", "Test Page",
                                             "--quiet"]))

        self.assertNotEqual(0, cmdline.main(["--build", "--quiet"]))

        # setup should work fine from anywhere
        self.assertEqual(0, cmdline.main(["--setup", "--quiet"]))
Ejemplo n.º 17
0
    def test_post_from_existing_file(self):
        # create file
        draft_file = os.path.join(utils.TEST_ROOT, "drafts", "draft_page.rst")

        with open(draft_file, "w") as f:
            f.write("Content")

        cmdline.main(["--page", draft_file, "--quiet"])

        file_path = os.path.join(utils.TEST_ROOT, "pages", "draft_page.rst")

        # assert file exists and check content
        self.assertTrue(os.path.exists(file_path))
        with open(file_path, "r") as f:
            self.assertEquals("Content", f.read())
Ejemplo n.º 18
0
    def test_post_from_path(self):
        # create file
        draft_file = os.path.join(utils.TEST_ROOT, "drafts", "draft_page.rst")

        with open(draft_file, "w") as f:
            f.write("Content")

        cmdline.main(["--page", draft_file, "--quiet"])

        file_path = os.path.join(utils.TEST_ROOT, "pages", "draft_page.rst")

        # assert file exists and check content
        self.assertTrue(os.path.exists(file_path))
        with open(file_path, "r") as f:
            self.assertEquals("Content", f.read())
Ejemplo n.º 19
0
 def test_missing_template(self):
     # creating a post with a missing template file should fail
     self.assertNotEqual(
         0,
         cmdline.main(["--post", "test", "--template", "missing",
                       "--quiet"])
     )
Ejemplo n.º 20
0
 def test_missing_template(self):
     # creating a post with a missing template file should fail
     self.assertNotEqual(
         0,
         cmdline.main(["--post", "test", "--template", "missing",
                       "--quiet"])
     )
Ejemplo n.º 21
0
    def test_setup(self):
        # blog is setup as part of test setup, tear it down and
        # re-create it via cmdline
        self.tearDown()
        cmdline.main(["--setup", "--quiet"])

        self.assertEqual(
            set(os.listdir(utils.TEST_ROOT)),
            set([
                "_static", "_templates", "drafts", "conf.py", "index.html",
                tinkerer.master_doc + ".rst"
            ]))

        # favicon should be copied to the blog _static folder
        self.assertTrue(
            os.path.exists(
                os.path.join(utils.TEST_ROOT, "_static", paths.favicon)))
Ejemplo n.º 22
0
    def test_post_from_path(self):
        # create file
        draft_file = os.path.join(utils.TEST_ROOT, "drafts", "draft_post.rst")

        with open(draft_file, "w") as f:
            f.write("Content")

        cmdline.main(["--post", draft_file, "--quiet"])

        # this might also fail at midnight :P
        year, month, day = tinkerer.utils.split_date()

        file_path = os.path.join(utils.TEST_ROOT, year, month, day, "draft_post.rst")

        # assert file exists and check content
        self.assertTrue(os.path.exists(file_path))
        with open(file_path, "r") as f:
            self.assertEquals("Content", f.read())
Ejemplo n.º 23
0
    def test_post_from_path(self):
        # create file
        draft_file = os.path.join(utils.TEST_ROOT, "drafts", "draft_post.rst")

        with open(draft_file, "w") as f:
            f.write("Content")

        cmdline.main(["--post", draft_file, "--quiet"])

        # this might also fail at midnight :P
        year, month, day = tinkerer.utils.split_date()

        file_path = os.path.join(utils.TEST_ROOT, year, month, day,
                                 "draft_post.rst")

        # assert file exists and check content
        self.assertTrue(os.path.exists(file_path))
        with open(file_path, "r") as f:
            self.assertEquals("Content", f.read())
Ejemplo n.º 24
0
    def test_setup(self):
        # blog is setup as part of test setup, tear it down and
        # re-create it via cmdline
        self.tearDown()
        cmdline.main(["--setup", "--quiet"])

        self.assertEqual(
            set(os.listdir(utils.TEST_ROOT)),
            set([
                "_static",
                "_templates",
                "drafts",
                "conf.py",
                "index.html",
                tinkerer.master_doc + ".rst"
            ]))

        # favicon should be copied to the blog _static folder
        self.assertTrue(os.path.exists(
            os.path.join(utils.TEST_ROOT, "_static", paths.favicon)
            ))
Ejemplo n.º 25
0
    def test_preview(self):
        # create a post
        new_post = post.create("A post", datetime.datetime(2010, 10, 1))

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

        # create a draft
        new_draft = draft.create("draft")
        self.assertTrue(os.path.exists(new_draft))

        # preview it (build should succeed)
        self.assertEqual(0, cmdline.main(["--preview", new_draft, "-q"]))

        # draft should not be in TOC
        for line in master.read_master():
            self.assertFalse("draft" in line)
Ejemplo n.º 26
0
    def test_preview(self):
        # create a post
        new_post = post.create("A post", datetime.datetime(2010, 10, 1))

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

        # create a draft
        new_draft = draft.create("draft")
        self.assertTrue(os.path.exists(new_draft))

        # preview it (build should succeed)
        self.assertEquals(0, cmdline.main(["--preview", new_draft, "-q"]))

        # draft should not be in TOC
        for line in master.read_master():
            self.assertFalse("draft" in line)
Ejemplo n.º 27
0
from tinkerer import cmdline
import sys

cmdline.main(sys.argv[1:])