Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #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"]))
Beispiel #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"]))
Beispiel #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))
Beispiel #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"]),
        )
Beispiel #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))
Beispiel #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"
            ]))
Beispiel #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"]))
Beispiel #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())
Beispiel #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())
Beispiel #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"]))
Beispiel #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())
Beispiel #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())
Beispiel #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"])
     )
Beispiel #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"])
     )
Beispiel #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)))
Beispiel #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())
Beispiel #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())
Beispiel #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)
            ))
Beispiel #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)
Beispiel #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)
Beispiel #27
0
from tinkerer import cmdline
import sys

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