當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。