示例#1
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)
示例#2
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)
示例#3
0
    def test_prepend(self):
        new_docs = ["somewhere/somedoc", "anotherdoc"]

        # first doc should be prepended in the correct place
        master.prepend_doc(new_docs[0])

        self.assertEquals(
            TestMaster.MASTER_HEAD + ["   %s\n" % new_docs[0]] +
            TestMaster.MASTER_TAIL, master.read_master())

        master.prepend_doc(new_docs[1])

        # order should be second doc then first doc
        self.assertEquals(
            TestMaster.MASTER_HEAD +
            ["   %s\n" % new_docs[1],
             "   %s\n" % new_docs[0]] + TestMaster.MASTER_TAIL,
            master.read_master())
示例#4
0
    def test_append(self):
        new_docs = ["somewhere/somedoc", "anotherdoc"]

        master.append_doc(new_docs[0])

        # first doc should be appendend in the correct place
        self.assertEquals(
            TestMaster.MASTER_HEAD + ["   %s\n" % new_docs[0]] +
            TestMaster.MASTER_TAIL, master.read_master())

        master.append_doc(new_docs[1])

        # second doc should be appended in the correct place
        self.assertEquals(
            TestMaster.MASTER_HEAD +
            ["   %s\n" % new_docs[0],
             "   %s\n" % new_docs[1]] + TestMaster.MASTER_TAIL,
            master.read_master())
示例#5
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)
示例#6
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)
示例#7
0
    def test_prepend(self):
        new_docs = ["somewhere/somedoc", "anotherdoc"]

        # first doc should be prepended in the correct place
        master.prepend_doc(new_docs[0])

        self.assertEquals(
            TestMaster.MASTER_HEAD +
            ["   %s\n" % new_docs[0]] +
            TestMaster.MASTER_TAIL,
            master.read_master())

        master.prepend_doc(new_docs[1])

        # order should be second doc then first doc
        self.assertEquals(
            TestMaster.MASTER_HEAD +
            ["   %s\n" % new_docs[1], "   %s\n" % new_docs[0]] +
            TestMaster.MASTER_TAIL,
            master.read_master())
示例#8
0
    def test_append(self):
        new_docs = ["somewhere/somedoc", "anotherdoc"]

        master.append_doc(new_docs[0])

        # first doc should be appendend in the correct place
        self.assertEquals(
            TestMaster.MASTER_HEAD +
            ["   %s\n" % new_docs[0]] +
            TestMaster.MASTER_TAIL,
            master.read_master())

        master.append_doc(new_docs[1])

        # second doc should be appended in the correct place
        self.assertEquals(
            TestMaster.MASTER_HEAD +
            ["   %s\n" % new_docs[0], "   %s\n" % new_docs[1]] +
            TestMaster.MASTER_TAIL,
            master.read_master())
示例#9
0
    def test_remove(self):
        # append 4 docs
        new_docs = ["a", "b", "c", "d"]
        for doc in new_docs:
            master.append_doc(doc)

        # remove 3 of them while checking master each time
        for doc_to_remove in ["c", "b", "d"]:
            master.remove_doc(doc_to_remove)
            new_docs.remove(doc_to_remove)

            self.assertEquals(
                TestMaster.MASTER_HEAD +
                ["   %s\n" % doc for doc in new_docs] + TestMaster.MASTER_TAIL,
                master.read_master())
示例#10
0
    def test_remove(self):
        # append 4 docs
        new_docs = ["a", "b", "c", "d"]
        for doc in new_docs:
            master.append_doc(doc)

        # remove 3 of them while checking master each time
        for doc_to_remove in ["c", "b", "d"]:
            master.remove_doc(doc_to_remove)
            new_docs.remove(doc_to_remove)

            self.assertEquals(
                TestMaster.MASTER_HEAD +
                ["   %s\n" % doc for doc in new_docs] +
                TestMaster.MASTER_TAIL,
                master.read_master())
示例#11
0
 def test_setup(self):
     self.assertEquals(TestMaster.MASTER_HEAD + TestMaster.MASTER_TAIL,
                       master.read_master())
示例#12
0
 def test_setup(self):
     self.assertEquals(
         TestMaster.MASTER_HEAD + TestMaster.MASTER_TAIL,
         master.read_master())