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


Python QuestionFactory.creator方法代码示例

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


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

示例1: test_asker_replies_arent_a_contribution

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import creator [as 别名]
    def test_asker_replies_arent_a_contribution(self):
        """Verify that replies posted by the question creator aren't counted.

        If a user has 10 replies to their own question, they aren't counted as
        a contributor.
        """
        # A user with 10 answers to own question.
        q = QuestionFactory()
        u = q.creator
        AnswerFactory.create_batch(10, creator=u, question=q)

        # Create metric kinds and update metrics for tomorrow (today's
        # activity shows up tomorrow).
        self._make_contributor_metric_kinds()
        update_contributor_metrics(day=date.today() + timedelta(days=1))

        r = self._get_api_result('api.kpi.contributors')
        eq_(r['objects'][0]['support_forum'], 0)

        # Change the question creator, now we should have 1 contributor.
        q.creator = UserFactory()
        q.save()
        cache.clear()  # We need to clear the cache for new results.

        Metric.objects.all().delete()
        update_contributor_metrics(day=date.today() + timedelta(days=1))

        r = self._get_api_result('api.kpi.contributors')
        eq_(r['objects'][0]['support_forum'], 1)
开发者ID:1234-,项目名称:kitsune,代码行数:31,代码来源:test_api.py


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