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


Python models.UserMappingType类代码示例

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


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

示例1: test_reindex_users_that_contributed_yesterday

    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,代码行数:35,代码来源:test_es.py

示例2: test_reindex_users_that_contributed_yesterday

    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,代码行数:32,代码来源:test_es.py

示例3: test_query_display_name_with_whitespace

    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,代码行数:9,代码来源:test_es.py

示例4: test_query_display_name_with_whitespace

    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,代码行数:10,代码来源:test_es.py

示例5: test_query_username_with_numbers

    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,代码行数:10,代码来源:test_es.py

示例6: test_suggest_completions_numbers

    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,代码行数:11,代码来源:test_es.py

示例7: test_last_contribution_date

    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,代码行数:54,代码来源:test_es.py

示例8: test_query_display_name_with_whitespace

    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,代码行数:11,代码来源:test_es.py

示例9: test_query_username_with_numbers

    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,代码行数:12,代码来源:test_es.py

示例10: test_add_and_delete

    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,代码行数:12,代码来源:test_es.py

示例11: test_query_username_with_numbers

    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,代码行数:13,代码来源:test_es.py

示例12: test_suggest_completions_numbers

    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,代码行数:13,代码来源:test_es.py

示例13: test_query_twitter_usernames

    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,代码行数:13,代码来源:test_es.py

示例14: test_data_in_index

    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,代码行数:16,代码来源:test_es.py

示例15: test_query_twitter_usernames

    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,代码行数:17,代码来源:test_es.py


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