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