def test_create_without_template(self, render): draft.create('no-template') render.assert_called_once_with( paths.post_template, mock.ANY, mock.ANY, )
def test_create_with_template(self, render): draft.create('with-template', template='the_template.rst') render.assert_called_once_with( 'the_template.rst', mock.ANY, mock.ANY, )
def test_create(self): # create draft with given title new_draft = draft.create("My Draft") self.assertEquals(os.path.abspath(os.path.join(utils.TEST_ROOT, "drafts", "my_draft.rst")), new_draft) self.assertTrue(os.path.exists(new_draft))
def test_create(self): # create draft with given title new_draft = draft.create("My Draft") self.assertEquals( os.path.abspath( os.path.join(utils.TEST_ROOT, "drafts", "my_draft.rst")), new_draft) self.assertTrue(os.path.exists(new_draft))
def test_content(self): # create draft with no content new_draft = draft.create("My Draft") # check expected empty post content with open(new_draft) as f: self.assertEquals(f.readlines(), [ "My Draft\n", "========\n", "\n", "\n", "\n", ".. author:: default\n", ".. categories:: none\n", ".. tags:: none\n", ".. comments::\n" ])
def create_draft(title, template): ''' Creates a new draft with the given title or makes an existing file a draft. ''' move = os.path.exists(title) if move: new_draft = draft.move(title) else: new_draft = draft.create(title, template) output.filename.info(new_draft) if move: output.write.info("File moved to draft '%s'" % new_draft) else: output.write.info("New draft created as '%s'" % new_draft)
def test_content(self): # create draft with no content new_draft = draft.create("My Draft") # check expected empty post content with open(new_draft) as f: self.assertEquals(f.readlines(), ["My Draft\n", "========\n", "\n", "\n", "\n", ".. author:: default\n", ".. categories:: none\n", ".. tags:: none\n", ".. comments::\n"])
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)
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)