本文整理汇总了Python中kitsune.wiki.models.DocumentMappingType.extract_document方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentMappingType.extract_document方法的具体用法?Python DocumentMappingType.extract_document怎么用?Python DocumentMappingType.extract_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kitsune.wiki.models.DocumentMappingType
的用法示例。
在下文中一共展示了DocumentMappingType.extract_document方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_translations_get_parent_tags
# 需要导入模块: from kitsune.wiki.models import DocumentMappingType [as 别名]
# 或者: from kitsune.wiki.models.DocumentMappingType import extract_document [as 别名]
def test_translations_get_parent_tags(self):
t1 = TopicFactory(display_order=1)
t2 = TopicFactory(display_order=2)
p = ProductFactory()
doc1 = DocumentFactory(
title=u'Audio too loud',
products=[p],
topics=[t1, t2])
RevisionFactory(document=doc1, is_approved=True)
doc2 = DocumentFactory(title=u'Audio too loud bork bork', parent=doc1, tags=[u'badtag'])
RevisionFactory(document=doc2, is_approved=True)
# Verify the parent has the right tags.
doc_dict = DocumentMappingType.extract_document(doc1.id)
eq_(sorted(doc_dict['topic']), sorted([t1.slug, t2.slug]))
eq_(doc_dict['product'], [p.slug])
# Verify the translation has the parent's tags.
doc_dict = DocumentMappingType.extract_document(doc2.id)
eq_(sorted(doc_dict['topic']), sorted([t1.slug, t2.slug]))
eq_(doc_dict['product'], [p.slug])
示例2: test_translations_get_parent_tags
# 需要导入模块: from kitsune.wiki.models import DocumentMappingType [as 别名]
# 或者: from kitsune.wiki.models.DocumentMappingType import extract_document [as 别名]
def test_translations_get_parent_tags(self):
doc1 = document(title=u'Audio too loud')
doc1.save()
revision(document=doc1, is_approved=True, save=True)
doc1.topics.add(topic(slug='cookies', save=True))
doc1.topics.add(topic(slug='general', save=True))
doc1.products.add(product(slug='desktop', save=True))
doc2 = document(title=u'Audio too loud bork bork',
parent=doc1)
doc2.save()
revision(document=doc2, is_approved=True, save=True)
doc2.tags.add(u'badtag')
# Verify the parent has the right tags.
doc_dict = DocumentMappingType.extract_document(doc1.id)
eq_(doc_dict['topic'], [u'cookies', u'general'])
eq_(doc_dict['product'], [u'desktop'])
# Verify the translation has the parent's tags.
doc_dict = DocumentMappingType.extract_document(doc2.id)
eq_(doc_dict['topic'], [u'cookies', u'general'])
eq_(doc_dict['product'], [u'desktop'])