本文整理汇总了Python中kitsune.wiki.tests.DocumentFactory.title方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentFactory.title方法的具体用法?Python DocumentFactory.title怎么用?Python DocumentFactory.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kitsune.wiki.tests.DocumentFactory
的用法示例。
在下文中一共展示了DocumentFactory.title方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_template_title_and_category_localized
# 需要导入模块: from kitsune.wiki.tests import DocumentFactory [as 别名]
# 或者: from kitsune.wiki.tests.DocumentFactory import title [as 别名]
def test_template_title_and_category_localized(self):
# Because localized articles are required to match templates with their
# parents, this deserves extra testing.
d_en = DocumentFactory()
d_fr = DocumentFactory(parent=d_en, locale='fr')
# Just changing the title isn't enough
d_fr.title = TEMPLATE_TITLE_PREFIX + d_fr.title
self.assertRaises(ValidationError, d_fr.save)
# Trying to change the category won't work, since `d_en` will force the
# old category.
d_fr = Document.objects.get(id=d_fr.id) # reset
d_fr.title = TEMPLATE_TITLE_PREFIX + d_fr.title
d_fr.category = TEMPLATES_CATEGORY
self.assertRaises(ValidationError, d_fr.save)
# Change the parent
d_en.title = TEMPLATE_TITLE_PREFIX + d_en.title
d_en.category = TEMPLATES_CATEGORY
d_en.save()
# Now the French article can be changed too.
d_fr = Document.objects.get(id=d_fr.id) # reset
d_fr.title = TEMPLATE_TITLE_PREFIX + d_fr.title
d_fr.category = TEMPLATES_CATEGORY
d_fr.save()
示例2: test_no_redirect_on_unsaved_change
# 需要导入模块: from kitsune.wiki.tests import DocumentFactory [as 别名]
# 或者: from kitsune.wiki.tests.DocumentFactory import title [as 别名]
def test_no_redirect_on_unsaved_change(self):
"""No redirect should be made when an unsaved doc's title or slug is
changed."""
d = DocumentFactory(title='Gerbil')
d.title = 'Weasel'
d.save()
# There should be no redirect from Gerbil -> Weasel:
assert not Document.objects.filter(title='Gerbil').exists()
示例3: test_document_is_template
# 需要导入模块: from kitsune.wiki.tests import DocumentFactory [as 别名]
# 或者: from kitsune.wiki.tests.DocumentFactory import title [as 别名]
def test_document_is_template(self):
"""is_template stays in sync with the title"""
d = DocumentFactory(title='test')
assert not d.is_template
d.title = TEMPLATE_TITLE_PREFIX + 'test'
d.category = TEMPLATES_CATEGORY
d.save()
assert d.is_template
d.title = 'Back to document'
d.category = CATEGORIES[0][0]
d.save()
assert not d.is_template
示例4: test_template_title_and_category_to_template
# 需要导入模块: from kitsune.wiki.tests import DocumentFactory [as 别名]
# 或者: from kitsune.wiki.tests.DocumentFactory import title [as 别名]
def test_template_title_and_category_to_template(self):
d = DocumentFactory()
# First, try and change just the title. It should fail.
d.title = TEMPLATE_TITLE_PREFIX + d.title
self.assertRaises(ValidationError, d.save)
# Next, try and change just the category. It should also fail.
d = Document.objects.get(id=d.id) # reset
d.category = TEMPLATES_CATEGORY
self.assertRaises(ValidationError, d.save)
# Finally, try and change both title and category. It should work.
d = Document.objects.get(id=d.id) # reset
d.title = TEMPLATE_TITLE_PREFIX + d.title
d.category = TEMPLATES_CATEGORY
d.save()