当前位置: 首页>>代码示例>>Python>>正文


Python DocumentFactory.links_from方法代码示例

本文整理汇总了Python中kitsune.wiki.tests.DocumentFactory.links_from方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentFactory.links_from方法的具体用法?Python DocumentFactory.links_from怎么用?Python DocumentFactory.links_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kitsune.wiki.tests.DocumentFactory的用法示例。


在下文中一共展示了DocumentFactory.links_from方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_unicode

# 需要导入模块: from kitsune.wiki.tests import DocumentFactory [as 别名]
# 或者: from kitsune.wiki.tests.DocumentFactory import links_from [as 别名]
    def test_unicode(self):
        """Unicode is hard. Test that."""
        # \u03C0 is pi and \u2764 is a heart symbol.
        d1 = DocumentFactory(title=u'\u03C0', slug='pi')
        ApprovedRevisionFactory(document=d1, content=u'I \u2764 \u03C0')
        d2 = DocumentFactory(title=u'\u2764', slug='heart')
        ApprovedRevisionFactory(document=d2, content=u'What do you think about [[\u03C0]]?')

        eq_(len(d1.links_to()), 1)
        eq_(len(d1.links_from()), 0)
        eq_(len(d2.links_to()), 0)
        eq_(len(d2.links_from()), 1)

        eq_(d1.links_to()[0].kind, 'link')
开发者ID:1234-,项目名称:kitsune,代码行数:16,代码来源:test_parser.py

示例2: test_locales_exists

# 需要导入模块: from kitsune.wiki.tests import DocumentFactory [as 别名]
# 或者: from kitsune.wiki.tests.DocumentFactory import links_from [as 别名]
    def test_locales_exists(self):
        """Links should use the correct locale."""
        d1 = DocumentFactory(title='Foo', locale='en-US')
        RevisionFactory(document=d1, content='', is_approved=True)
        d2 = DocumentFactory(title='Foo', locale='de')
        RevisionFactory(document=d2, content='', is_approved=True)
        d3 = DocumentFactory(title='Bar', locale='de')
        RevisionFactory(document=d3, content='[[Foo]]', is_approved=True)

        eq_(len(d1.links_to()), 0)
        eq_(len(d1.links_from()), 0)
        eq_(len(d2.links_to()), 1)
        eq_(len(d2.links_from()), 0)
        eq_(len(d3.links_to()), 0)
        eq_(len(d3.links_from()), 1)

        eq_(d2.links_to()[0].kind, 'link')
开发者ID:1234-,项目名称:kitsune,代码行数:19,代码来源:test_parser.py

示例3: test_locales_renames

# 需要导入模块: from kitsune.wiki.tests import DocumentFactory [as 别名]
# 或者: from kitsune.wiki.tests.DocumentFactory import links_from [as 别名]
    def test_locales_renames(self):
        """Links should use the correct locale, even if the title has
        been translated."""
        d1 = DocumentFactory(title='Foo', locale='en-US')
        RevisionFactory(document=d1, content='', is_approved=True)
        d2 = DocumentFactory(title='German Foo', locale='de', parent=d1)
        RevisionFactory(document=d2, content='', is_approved=True)
        d3 = DocumentFactory(title='German Bar', locale='de')
        RevisionFactory(document=d3, content='[[Foo]]', is_approved=True)

        eq_(len(d1.links_to()), 0)
        eq_(len(d1.links_from()), 0)
        eq_(len(d2.links_to()), 1)
        eq_(len(d2.links_from()), 0)
        eq_(len(d3.links_to()), 0)
        eq_(len(d3.links_from()), 1)

        eq_(d2.links_to()[0].kind, 'link')
开发者ID:1234-,项目名称:kitsune,代码行数:20,代码来源:test_parser.py

示例4: test_old_revisions

# 需要导入模块: from kitsune.wiki.tests import DocumentFactory [as 别名]
# 或者: from kitsune.wiki.tests.DocumentFactory import links_from [as 别名]
    def test_old_revisions(self):
        """Bug 862436. Updating old revisions could cause bad WLH data."""
        d1 = DocumentFactory(title='D1')
        RevisionFactory(document=d1, content='', is_approved=True)
        d2 = DocumentFactory(title='D2')
        RevisionFactory(document=d2, content='', is_approved=True)

        # Make D3, then make a revision that links to D1, then a
        # revision that links to D2. Only the link to D2 should count.
        d3 = DocumentFactory(title='D3')
        r3_old = ApprovedRevisionFactory(document=d3, content='[[D1]]')
        ApprovedRevisionFactory(document=d3, content='[[D2]]')

        # This could cause stale data
        r3_old.content_parsed

        # D1 is not linked to in any current revisions.
        eq_(len(d1.links_to()), 0)
        eq_(len(d1.links_from()), 0)
        eq_(len(d2.links_to()), 1)
        eq_(len(d2.links_from()), 0)
        eq_(len(d3.links_to()), 0)
        eq_(len(d3.links_from()), 1)
开发者ID:1234-,项目名称:kitsune,代码行数:25,代码来源:test_parser.py


注:本文中的kitsune.wiki.tests.DocumentFactory.links_from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。