本文整理汇总了Python中kitsune.questions.models.Question.recent_asked_count方法的典型用法代码示例。如果您正苦于以下问题:Python Question.recent_asked_count方法的具体用法?Python Question.recent_asked_count怎么用?Python Question.recent_asked_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kitsune.questions.models.Question
的用法示例。
在下文中一共展示了Question.recent_asked_count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_recent_counts_with_filter
# 需要导入模块: from kitsune.questions.models import Question [as 别名]
# 或者: from kitsune.questions.models.Question import recent_asked_count [as 别名]
def test_recent_counts_with_filter(self):
"""Verify that recent_asked_count and recent_unanswered_count
respect filters passed."""
now = datetime.now()
question(created=now, locale='en-US', save=True)
q = question(created=now, locale='en-US', save=True)
answer(question=q, save=True)
question(created=now, locale='pt-BR', save=True)
question(created=now, locale='pt-BR', save=True)
q = question(created=now, locale='pt-BR', save=True)
answer(question=q, save=True)
# 5 asked recently, 3 are unanswered
eq_(5, Question.recent_asked_count())
eq_(3, Question.recent_unanswered_count())
# check english (2 asked, 1 unanswered)
locale_filter = Q(locale='en-US')
eq_(2, Question.recent_asked_count(locale_filter))
eq_(1, Question.recent_unanswered_count(locale_filter))
# check pt-BR (3 asked, 2 unanswered)
locale_filter = Q(locale='pt-BR')
eq_(3, Question.recent_asked_count(locale_filter))
eq_(2, Question.recent_unanswered_count(locale_filter))
示例2: test_recent_counts
# 需要导入模块: from kitsune.questions.models import Question [as 别名]
# 或者: from kitsune.questions.models.Question import recent_asked_count [as 别名]
def test_recent_counts(self):
"""Verify recent_asked_count and recent unanswered count."""
# create a question for each of past 4 days
now = datetime.now()
question(created=now, save=True)
question(created=now - timedelta(hours=12), save=True, is_locked=True)
q = question(created=now - timedelta(hours=23), save=True)
answer(question=q, save=True)
# 25 hours instead of 24 to avoid random test fails.
question(created=now - timedelta(hours=25), save=True)
# Only 3 are recent from last 72 hours, 1 has an answer.
eq_(3, Question.recent_asked_count())
eq_(1, Question.recent_unanswered_count())