本文整理汇总了Python中tinkerer.page.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_without_template
def test_create_without_template(self, render):
page.create('no-template')
render.assert_called_once_with(
paths.page_template,
mock.ANY,
mock.ANY,
)
示例2: test_create_with_template
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,
)
示例3: test_landingpage
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")))
示例4: build_theme
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()
示例5: test_master_update
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])
示例6: test_ordering
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()
示例7: test_metadata
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()
示例8: test_move
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)
示例9: test_content
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"])
示例10: test_create
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)
示例11: test_nolandingpage
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")))
示例12: create_page
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)
示例13: test_move_duplicate
def test_move_duplicate(self):
# create initial page
page.create("Page1")
# should raise
page.move("Page1")
示例14: test_create_duplicate
def test_create_duplicate(self):
# create initial post
page.create("Page1")
# should raise
page.create("Page1")