本文整理汇总了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())
示例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())
示例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)
示例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)
示例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)
示例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'])
示例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)
示例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)
示例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)
示例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)
示例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)
示例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"])
示例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']
示例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)
示例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']