本文整理汇总了Python中shoppingcart.models.Coupon.__unicode__方法的典型用法代码示例。如果您正苦于以下问题:Python Coupon.__unicode__方法的具体用法?Python Coupon.__unicode__怎么用?Python Coupon.__unicode__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shoppingcart.models.Coupon
的用法示例。
在下文中一共展示了Coupon.__unicode__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_soft_delete_coupon
# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import __unicode__ [as 别名]
def test_soft_delete_coupon(self): # pylint: disable=E1101
self.add_coupon(self.course_key, True)
coupon = Coupon(code='TestCode', description='testing', course_id=self.course_key,
percentage_discount=12, created_by=self.user, is_active=True)
coupon.save()
self.assertEquals(coupon.__unicode__(), '[Coupon] code: TestCode course: MITx/999/Robot_Super_Course')
admin = User.objects.create_user('Mark', '[email protected]', 'foo')
admin.is_staff = True
get_coupon = Coupon.objects.get(id=1)
request = HttpRequest()
request.user = admin
setattr(request, 'session', 'session') # pylint: disable=E1101
messages = FallbackStorage(request) # pylint: disable=E1101
setattr(request, '_messages', messages) # pylint: disable=E1101
coupon_admin = SoftDeleteCouponAdmin(Coupon, AdminSite())
test_query_set = coupon_admin.queryset(request)
test_actions = coupon_admin.get_actions(request)
self.assertTrue('really_delete_selected' in test_actions['really_delete_selected'])
self.assertEqual(get_coupon.is_active, True)
coupon_admin.really_delete_selected(request, test_query_set) # pylint: disable=E1101
for coupon in test_query_set:
self.assertEqual(coupon.is_active, False)
coupon_admin.delete_model(request, get_coupon) # pylint: disable=E1101
self.assertEqual(get_coupon.is_active, False)
coupon = Coupon(code='TestCode123', description='testing123', course_id=self.course_key,
percentage_discount=22, created_by=self.user, is_active=True)
coupon.save()
test_query_set = coupon_admin.queryset(request)
coupon_admin.really_delete_selected(request, test_query_set) # pylint: disable=E1101
for coupon in test_query_set:
self.assertEqual(coupon.is_active, False)