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


Python KarmaManager.total_count方法代码示例

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


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

示例1: KarmaActionTests

# 需要导入模块: from karma.manager import KarmaManager [as 别名]
# 或者: from karma.manager.KarmaManager import total_count [as 别名]
class KarmaActionTests(TestCase):
    def setUp(self):
        super(KarmaActionTests, self).setUp()
        self.user = user(save=True)
        try:
            self.mgr = KarmaManager()
            redis_client('karma').flushdb()
        except RedisError:
            raise SkipTest

    @mock.patch.object(waffle, 'switch_is_active')
    def test_action(self, switch_is_active):
        """Save an action and verify."""
        switch_is_active.return_value = True
        TestAction1(user=self.user).save()
        eq_(3, self.mgr.total_points(self.user))
        eq_(1, self.mgr.total_count(TestAction1, self.user))
        today = date.today()
        eq_(1, self.mgr.day_count(TestAction1, self.user, today))
        eq_(1, self.mgr.month_count(TestAction1, self.user, today.year,
                                    today.month))
        eq_(1, self.mgr.year_count(TestAction1, self.user, today.year))

    @mock.patch.object(waffle, 'switch_is_active')
    def test_two_actions(self, switch_is_active):
        """Save two actions, one twice, and verify."""
        switch_is_active.return_value = True
        TestAction1(user=self.user).save()
        TestAction2(user=self.user).save()
        TestAction2(user=self.user).save()
        eq_(17, self.mgr.total_points(self.user))
        eq_(1, self.mgr.total_count(TestAction1, self.user))
        eq_(2, self.mgr.total_count(TestAction2, self.user))
        today = date.today()
        eq_(1, self.mgr.day_count(TestAction1, self.user, today))
        eq_(1, self.mgr.month_count(TestAction1, self.user, today.year,
                                    today.month))
        eq_(1, self.mgr.year_count(TestAction1, self.user, today.year))
        eq_(2, self.mgr.day_count(TestAction2, self.user, today))
        eq_(2, self.mgr.month_count(TestAction2, self.user, today.year,
                                    today.month))
        eq_(2, self.mgr.year_count(TestAction2, self.user, today.year))
开发者ID:fox2mike,项目名称:kitsune,代码行数:44,代码来源:test_actions.py


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