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


Python UserMappingType.suggest_completions方法代码示例

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


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

示例1: test_suggest_completions

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import suggest_completions [as 别名]
    def test_suggest_completions(self):
        u1 = UserFactory(username='r1cky', profile__name=u'Rick Róss')
        u2 = UserFactory(username='Willkg', profile__name=u'Will Cage')

        self.refresh()
        eq_(UserMappingType.search().count(), 2)

        results = UserMappingType.suggest_completions('wi')
        eq_(1, len(results))
        eq_('Will Cage (Willkg)', results[0]['text'])
        eq_(u2.id, results[0]['payload']['user_id'])

        results = UserMappingType.suggest_completions('R1')
        eq_(1, len(results))
        eq_(u'Rick Róss (r1cky)', results[0]['text'])
        eq_(u1.id, results[0]['payload']['user_id'])

        # Add another Ri....
        UserFactory(username='richard', profile__name=u'Richard Smith')

        self.refresh()
        eq_(UserMappingType.search().count(), 3)

        results = UserMappingType.suggest_completions('ri')
        eq_(2, len(results))
        texts = [r['text'] for r in results]
        assert u'Rick Róss (r1cky)' in texts
        assert u'Richard Smith (richard)' in texts

        results = UserMappingType.suggest_completions(u'Rick Ró')
        eq_(1, len(results))
        texts = [r['text'] for r in results]
        eq_(u'Rick Róss (r1cky)', results[0]['text'])
开发者ID:1234-,项目名称:kitsune,代码行数:35,代码来源:test_es.py

示例2: test_suggest_completions_numbers

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import suggest_completions [as 别名]
    def test_suggest_completions_numbers(self):
        u1 = UserFactory(username='1337mike', profile__name=u'Elite Mike')
        UserFactory(username='crazypants', profile__name=u'Crazy Pants')

        self.refresh()
        eq_(UserMappingType.search().count(), 2)

        results = UserMappingType.suggest_completions('13')
        eq_(1, len(results))
        eq_('Elite Mike (1337mike)', results[0]['text'])
        eq_(u1.id, results[0]['payload']['user_id'])
开发者ID:1234-,项目名称:kitsune,代码行数:13,代码来源:test_es.py

示例3: test_suggest_completions_numbers

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import suggest_completions [as 别名]
    def test_suggest_completions_numbers(self):
        u1 = user(username="1337mike", save=True)
        profile(user=u1, name=u"Elite Mike")
        u2 = user(username="crazypants", save=True)
        profile(user=u2, name=u"Crazy Pants")

        self.refresh()
        eq_(UserMappingType.search().count(), 2)

        results = UserMappingType.suggest_completions("13")
        eq_(1, len(results))
        eq_("Elite Mike (1337mike)", results[0]["text"])
        eq_(u1.id, results[0]["payload"]["user_id"])
开发者ID:Zucus,项目名称:kitsune,代码行数:15,代码来源:test_es.py

示例4: test_suggest_completions

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import suggest_completions [as 别名]
    def test_suggest_completions(self):
        u1 = user(username="r1cky", save=True)
        profile(user=u1, name=u"Rick Róss")
        u2 = user(username="Willkg", save=True)
        profile(user=u2, name=u"Will Cage")

        self.refresh()
        eq_(UserMappingType.search().count(), 2)

        results = UserMappingType.suggest_completions("wi")
        eq_(1, len(results))
        eq_("Will Cage (Willkg)", results[0]["text"])
        eq_(u2.id, results[0]["payload"]["user_id"])

        results = UserMappingType.suggest_completions("R1")
        eq_(1, len(results))
        eq_(u"Rick Róss (r1cky)", results[0]["text"])
        eq_(u1.id, results[0]["payload"]["user_id"])

        # Add another Ri....
        u3 = user(username="richard", save=True)
        profile(user=u3, name=u"Richard Smith")

        self.refresh()
        eq_(UserMappingType.search().count(), 3)

        results = UserMappingType.suggest_completions("ri")
        eq_(2, len(results))
        texts = [r["text"] for r in results]
        assert u"Rick Róss (r1cky)" in texts
        assert u"Richard Smith (richard)" in texts

        results = UserMappingType.suggest_completions(u"Rick Ró")
        eq_(1, len(results))
        texts = [r["text"] for r in results]
        eq_(u"Rick Róss (r1cky)", results[0]["text"])
开发者ID:Zucus,项目名称:kitsune,代码行数:38,代码来源:test_es.py


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