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


Python ActionMember.points_awarded方法代码示例

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


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

示例1: testVariablePointAchievement

# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import points_awarded [as 别名]
    def testVariablePointAchievement(self):
        """Test that a variable point activity appears correctly in the my achievements list."""
        activity = Activity(
            title="Test activity",
            slug="test-activity",
            description="Variable points!",
            duration=10,
            point_range_start=5,
            point_range_end=314160,
            pub_date=datetime.datetime.today(),
            expire_date=datetime.datetime.today() + datetime.timedelta(days=7),
            confirm_type="text",
            type="activity",
        )
        activity.save()

        points = self.user.get_profile().points()
        member = ActionMember(
            user=self.user,
            action=activity,
            approval_status="approved",
        )
        member.points_awarded = 314159
        member.save()

        self.assertEqual(self.user.get_profile().points(), points + 314159,
            "Variable number of points should have been awarded.")

        # Kludge to change point value for the info bar.
        profile = self.user.get_profile()
        profile.add_points(3, datetime.datetime.today(), "test")
        profile.save()

        response = self.client.get(reverse("profile_index"))
        self.assertContains(response,
            reverse("activity_task", args=(activity.type, activity.slug,)))
        # Note, this test may break if something in the page has the value 314159.
        # Try finding another suitable number.
        # print response.content
        self.assertContains(response, "314159", count=5,
            msg_prefix="314159 points should appear for the activity.")
开发者ID:gregorylburgess,项目名称:makahiki,代码行数:43,代码来源:tests.py


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