本文整理汇总了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)