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


Python UserMappingType.search方法代码示例

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


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

示例1: test_reindex_users_that_contributed_yesterday

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_reindex_users_that_contributed_yesterday(self):
        yesterday = datetime.now() - timedelta(days=1)

        # Verify for answers.
        u = user(username='answerer', save=True)
        profile(user=u)
        answer(creator=u, created=yesterday, save=True)

        reindex_users_that_contributed_yesterday()
        self.refresh()

        data = UserMappingType.search().query(username__match='answerer')[0]
        eq_(data['last_contribution_date'].date(), yesterday.date())

        # Verify for edits.
        u = user(username='editor', save=True)
        profile(user=u)
        revision(creator=u, created=yesterday, save=True)

        reindex_users_that_contributed_yesterday()
        self.refresh()

        data = UserMappingType.search().query(username__match='editor')[0]
        eq_(data['last_contribution_date'].date(), yesterday.date())

        # Verify for reviews.
        u = user(username='reviewer', save=True)
        profile(user=u)
        revision(reviewer=u, reviewed=yesterday, save=True)

        reindex_users_that_contributed_yesterday()
        self.refresh()

        data = UserMappingType.search().query(username__match='reviewer')[0]
        eq_(data['last_contribution_date'].date(), yesterday.date())
开发者ID:Archaeopteryx,项目名称:kitsune,代码行数:37,代码来源:test_es.py

示例2: test_reindex_users_that_contributed_yesterday

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_reindex_users_that_contributed_yesterday(self):
        yesterday = datetime.now() - timedelta(days=1)

        # Verify for answers.
        u = UserFactory(username='answerer')
        AnswerFactory(creator=u, created=yesterday)

        call_command('reindex_users_that_contributed_yesterday')
        self.refresh()

        data = UserMappingType.search().query(username__match='answerer')[0]
        eq_(data['last_contribution_date'].date(), yesterday.date())

        # Verify for edits.
        u = UserFactory(username='editor')
        RevisionFactory(creator=u, created=yesterday)

        call_command('reindex_users_that_contributed_yesterday')
        self.refresh()

        data = UserMappingType.search().query(username__match='editor')[0]
        eq_(data['last_contribution_date'].date(), yesterday.date())

        # Verify for reviews.
        u = UserFactory(username='reviewer')
        RevisionFactory(reviewer=u, reviewed=yesterday)

        call_command('reindex_users_that_contributed_yesterday')
        self.refresh()

        data = UserMappingType.search().query(username__match='reviewer')[0]
        eq_(data['last_contribution_date'].date(), yesterday.date())
开发者ID:akatsoulas,项目名称:kitsune,代码行数:34,代码来源:test_es.py

示例3: test_suggest_completions

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [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

示例4: test_query_display_name_with_whitespace

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_query_display_name_with_whitespace(self):
        UserFactory(username='1337miKE', profile__name=u'Elite Mike')
        UserFactory(username='mike', profile__name=u'NotElite Mike')

        self.refresh()

        eq_(UserMappingType.search().count(), 2)
        eq_(UserMappingType.search().query(
            idisplay_name__match_whitespace='elite').count(), 1)
开发者ID:1234-,项目名称:kitsune,代码行数:11,代码来源:test_es.py

示例5: test_query_display_name_with_whitespace

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

        self.refresh()

        eq_(UserMappingType.search().count(), 2)
        eq_(UserMappingType.search().query(idisplay_name__match_whitespace="elite").count(), 1)
开发者ID:Zucus,项目名称:kitsune,代码行数:12,代码来源:test_es.py

示例6: test_query_username_with_numbers

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_query_username_with_numbers(self):
        u = UserFactory(username='1337miKE', profile__name=u'Elite Mike')
        UserFactory(username='mike', profile__name=u'NotElite Mike')

        self.refresh()

        eq_(UserMappingType.search().query(iusername__match='1337mike').count(), 1)
        data = UserMappingType.search().query(iusername__match='1337mike')[0]
        eq_(data['username'], u.username)
        eq_(data['display_name'], u.profile.name)
开发者ID:1234-,项目名称:kitsune,代码行数:12,代码来源:test_es.py

示例7: test_query_display_name_with_whitespace

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_query_display_name_with_whitespace(self):
        u1 = user(username='1337miKE', save=True)
        profile(user=u1, name=u'Elite Mike')
        u2 = user(username='mike', save=True)
        profile(user=u2, name=u'NotElite Mike')

        self.refresh()

        eq_(UserMappingType.search().count(), 2)
        eq_(UserMappingType.search().query(
            idisplay_name__match_whitespace='elite').count(), 1)
开发者ID:Archaeopteryx,项目名称:kitsune,代码行数:13,代码来源:test_es.py

示例8: test_last_contribution_date

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_last_contribution_date(self):
        """Verify the last_contribution_date field works properly."""
        u = user(username='satdav', save=True)
        p = profile(user=u)

        self.refresh()

        data = UserMappingType.search().query(
            username__match='satdav').values_dict()[0]
        assert not data['last_contribution_date']

        # Add a AoA reply. It should be the last contribution.
        d = datetime(2014, 1, 1)
        reply(user=u, created=d, save=True)

        p.save()  # we need to resave the profile to force a reindex
        self.refresh()

        data = UserMappingType.search().query(
            username__match='satdav').values_dict()[0]
        eq_(data['last_contribution_date'], d)

        # Add a Support Forum answer. It should be the last contribution.
        d = datetime(2014, 1, 2)
        answer(creator=u, created=d, save=True)

        p.save()  # we need to resave the profile to force a reindex
        self.refresh()

        data = UserMappingType.search().query(
            username__match='satdav').values_dict()[0]
        eq_(data['last_contribution_date'], d)

        # Add a Revision edit. It should be the last contribution.
        d = datetime(2014, 1, 3)
        revision(creator=u, created=d, save=True)

        p.save()  # we need to resave the profile to force a reindex
        self.refresh()

        data = UserMappingType.search().query(
            username__match='satdav').values_dict()[0]
        eq_(data['last_contribution_date'], d)

        # Add a Revision review. It should be the last contribution.
        d = datetime(2014, 1, 4)
        revision(reviewer=u, reviewed=d, save=True)

        p.save()  # we need to resave the profile to force a reindex
        self.refresh()

        data = UserMappingType.search().query(
            username__match='satdav').values_dict()[0]
        eq_(data['last_contribution_date'], d)
开发者ID:doismellburning,项目名称:kitsune,代码行数:56,代码来源:test_es.py

示例9: test_add_and_delete

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_add_and_delete(self):
        """Adding a user with a profile should add it to the index.

        Deleting should delete it.
        """
        p = profile()
        self.refresh()
        eq_(UserMappingType.search().count(), 1)

        p.user.delete()
        self.refresh()
        eq_(UserMappingType.search().count(), 0)
开发者ID:Archaeopteryx,项目名称:kitsune,代码行数:14,代码来源:test_es.py

示例10: test_query_username_with_numbers

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

        self.refresh()

        eq_(UserMappingType.search().query(iusername__match="1337mike").count(), 1)
        data = UserMappingType.search().query(iusername__match="1337mike").values_dict()[0]
        eq_(data["username"], p.user.username)
        eq_(data["display_name"], p.name)
开发者ID:Zucus,项目名称:kitsune,代码行数:14,代码来源:test_es.py

示例11: test_query_username_with_numbers

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_query_username_with_numbers(self):
        u1 = user(username='1337miKE', save=True)
        p = profile(user=u1, name=u'Elite Mike')
        u2 = user(username='mike', save=True)
        profile(user=u2, name=u'NotElite Mike')

        self.refresh()

        eq_(UserMappingType.search().query(
            iusername__match='1337mike').count(), 1)
        data = UserMappingType.search().query(iusername__match='1337mike')[0]
        eq_(data['username'], p.user.username)
        eq_(data['display_name'], p.name)
开发者ID:Archaeopteryx,项目名称:kitsune,代码行数:15,代码来源:test_es.py

示例12: test_query_twitter_usernames

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_query_twitter_usernames(self):
        u1 = UserFactory(username='1337miKE', profile__name=u'Elite Mike')
        u2 = UserFactory(username='mike', profile__name=u'NotElite Mike')
        r1 = ReplyFactory(user=u1, twitter_username='l33tmIkE')
        ReplyFactory(user=u2, twitter_username='mikey')

        self.refresh()

        eq_(UserMappingType.search().query(itwitter_usernames__match='l33tmike').count(), 1)
        data = UserMappingType.search().query(itwitter_usernames__match='l33tmike')[0]
        eq_(data['username'], u1.username)
        eq_(data['display_name'], u1.profile.name)
        assert r1.twitter_username in data['twitter_usernames']
开发者ID:1234-,项目名称:kitsune,代码行数:15,代码来源:test_es.py

示例13: test_data_in_index

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_data_in_index(self):
        """Verify the data we are indexing."""
        u = user(username="r1cky", email="[email protected]", save=True)
        p = profile(user=u, name=u"Rick Róss")

        self.refresh()

        eq_(UserMappingType.search().count(), 1)
        data = UserMappingType.search().values_dict()[0]
        eq_(data["username"], p.user.username)
        eq_(data["display_name"], p.name)

        u = user(username="willkg", email="[email protected]", save=True)
        p = profile(user=u, name=u"Will Cage")
        self.refresh()
        eq_(UserMappingType.search().count(), 2)
开发者ID:Zucus,项目名称:kitsune,代码行数:18,代码来源:test_es.py

示例14: test_query_twitter_usernames

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_query_twitter_usernames(self):
        u1 = user(username='1337miKE', save=True)
        p = profile(user=u1, name=u'Elite Mike')
        u2 = user(username='mike', save=True)
        profile(user=u2, name=u'NotElite Mike')
        r1 = reply(user=u1, twitter_username='l33tmIkE', save=True)
        reply(user=u2, twitter_username='mikey', save=True)

        self.refresh()

        eq_(UserMappingType.search().query(
            itwitter_usernames__match='l33tmike').count(), 1)
        data = UserMappingType.search().query(
            itwitter_usernames__match='l33tmike')[0]
        eq_(data['username'], p.user.username)
        eq_(data['display_name'], p.name)
        assert r1.twitter_username in data['twitter_usernames']
开发者ID:Archaeopteryx,项目名称:kitsune,代码行数:19,代码来源:test_es.py

示例15: test_data_in_index

# 需要导入模块: from kitsune.users.models import UserMappingType [as 别名]
# 或者: from kitsune.users.models.UserMappingType import search [as 别名]
    def test_data_in_index(self):
        """Verify the data we are indexing."""
        u = UserFactory(username='r1cky', email='[email protected]', profile__name=u'Rick Róss')
        r1 = ReplyFactory(user=u, twitter_username='r1cardo')
        r2 = ReplyFactory(user=u, twitter_username='r1cky')

        self.refresh()

        eq_(UserMappingType.search().count(), 1)
        data = UserMappingType.search()[0]
        eq_(data['username'], u.username)
        eq_(data['display_name'], u.profile.name)
        assert r1.twitter_username in data['twitter_usernames']
        assert r2.twitter_username in data['twitter_usernames']

        u = UserFactory(username='willkg', email='[email protected]', profile__name='Will Cage')
        self.refresh()
        eq_(UserMappingType.search().count(), 2)
开发者ID:1234-,项目名称:kitsune,代码行数:20,代码来源:test_es.py


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