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


Python Question.recent_unanswered_count方法代码示例

本文整理汇总了Python中kitsune.questions.models.Question.recent_unanswered_count方法的典型用法代码示例。如果您正苦于以下问题:Python Question.recent_unanswered_count方法的具体用法?Python Question.recent_unanswered_count怎么用?Python Question.recent_unanswered_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kitsune.questions.models.Question的用法示例。


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

示例1: test_recent_counts_with_filter

# 需要导入模块: from kitsune.questions.models import Question [as 别名]
# 或者: from kitsune.questions.models.Question import recent_unanswered_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))
开发者ID:Cherpak,项目名称:kitsune,代码行数:29,代码来源:test_models.py

示例2: test_recent_counts

# 需要导入模块: from kitsune.questions.models import Question [as 别名]
# 或者: from kitsune.questions.models.Question import recent_unanswered_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())
开发者ID:Cherpak,项目名称:kitsune,代码行数:16,代码来源:test_models.py


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