本文整理汇总了Python中kitsune.questions.tests.QuestionFactory.num_votes_past_week方法的典型用法代码示例。如果您正苦于以下问题:Python QuestionFactory.num_votes_past_week方法的具体用法?Python QuestionFactory.num_votes_past_week怎么用?Python QuestionFactory.num_votes_past_week使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kitsune.questions.tests.QuestionFactory
的用法示例。
在下文中一共展示了QuestionFactory.num_votes_past_week方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cron_updates_counts
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import num_votes_past_week [as 别名]
def test_cron_updates_counts(self):
q = QuestionFactory()
self.refresh()
eq_(q.num_votes_past_week, 0)
# NB: Need to call .values_dict() here and later otherwise we
# get a Question object which has data from the database and
# not the index.
document = (QuestionMappingType.search()
.filter(id=q.id))[0]
eq_(document['question_num_votes_past_week'], 0)
QuestionVoteFactory(question=q, anonymous_id='abc123')
q.num_votes_past_week = 0
q.save()
update_weekly_votes()
self.refresh()
q = Question.objects.get(pk=q.pk)
eq_(1, q.num_votes_past_week)
document = (QuestionMappingType.search()
.filter(id=q.id))[0]
eq_(document['question_num_votes_past_week'], 1)
示例2: test_update_question_vote_chunk
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import num_votes_past_week [as 别名]
def test_update_question_vote_chunk(self):
# Reset the num_votes_past_week counts, I suspect the data gets
# loaded before I disconnect the signal and they get zeroed out.
q1 = QuestionFactory()
QuestionVoteFactory(question=q1)
q1.num_votes_past_week = 1
q1.save()
q2 = QuestionFactory()
# Actually test the task.
qs = Question.objects.all().order_by('-num_votes_past_week')
eq_(q1.pk, qs[0].pk)
QuestionVoteFactory(question=q2)
QuestionVoteFactory(question=q2)
qs = Question.objects.all().order_by('-num_votes_past_week')
eq_(q1.pk, qs[0].pk)
update_question_vote_chunk([q.pk for q in qs])
qs = Question.objects.all().order_by('-num_votes_past_week')
eq_(q2.pk, qs[0].pk)