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


Python Coupon.is_active方法代码示例

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


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

示例1: test_get_coupon_info

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import is_active [as 别名]
    def test_get_coupon_info(self):
        """
        Test Edit Coupon Info Scenarios. Handle all the HttpResponses return by edit_coupon_info view
        """
        coupon = Coupon(
            code='AS452', description='asdsadsa', course_id=self.course.id.to_deprecated_string(),
            percentage_discount=10, created_by=self.instructor
        )
        coupon.save()
        # URL for edit_coupon_info
        edit_url = reverse('get_coupon_info', kwargs={'course_id': self.course.id.to_deprecated_string()})
        response = self.client.post(edit_url, {'id': coupon.id})
        self.assertTrue('coupon with the coupon id ({coupon_id}) updated successfully'.format(coupon_id=coupon.id) in response.content)

        response = self.client.post(edit_url, {'id': 444444})
        self.assertTrue('coupon with the coupon id ({coupon_id}) DoesNotExist'.format(coupon_id=444444) in response.content)

        response = self.client.post(edit_url, {'id': ''})
        self.assertTrue('coupon id not found"' in response.content)

        coupon.is_active = False
        coupon.save()

        response = self.client.post(edit_url, {'id': coupon.id})
        self.assertTrue("coupon with the coupon id ({coupon_id}) is already inactive".format(coupon_id=coupon.id) in response.content)
开发者ID:victorchi2009,项目名称:edx-platform,代码行数:27,代码来源:test_ecommerce.py

示例2: test_delete_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import is_active [as 别名]
    def test_delete_coupon(self):
        """
        Test Delete Coupon Scenarios. Handle all the HttpResponses return by remove_coupon view
        """
        coupon = Coupon(
            code='AS452', description='asdsadsa', course_id=self.course.id.to_deprecated_string(),
            percentage_discount=10, created_by=self.instructor
        )

        coupon.save()

        response = self.client.post(self.url)
        self.assertTrue('<td>AS452</td>' in response.content)

        # URL for remove_coupon
        delete_coupon_url = reverse('remove_coupon', kwargs={'course_id': self.course.id.to_deprecated_string()})
        response = self.client.post(delete_coupon_url, {'id': coupon.id})
        self.assertTrue('coupon with the coupon id ({coupon_id}) updated successfully'.format(coupon_id=coupon.id) in response.content)

        coupon.is_active = False
        coupon.save()

        response = self.client.post(delete_coupon_url, {'id': coupon.id})
        self.assertTrue('coupon with the coupon id ({coupon_id}) is already inactive'.format(coupon_id=coupon.id) in response.content)

        response = self.client.post(delete_coupon_url, {'id': 24454})
        self.assertTrue('coupon with the coupon id ({coupon_id}) DoesNotExist'.format(coupon_id=24454) in response.content)

        response = self.client.post(delete_coupon_url, {'id': ''})
        self.assertTrue('coupon id is None' in response.content)
开发者ID:victorchi2009,项目名称:edx-platform,代码行数:32,代码来源:test_ecommerce.py

示例3: test_get_coupon_info

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import is_active [as 别名]
    def test_get_coupon_info(self):
        """
        Test Edit Coupon Info Scenarios. Handle all the HttpResponses return by edit_coupon_info view
        """
        coupon = Coupon(
            code="AS452",
            description="asdsadsa",
            course_id=self.course.id.to_deprecated_string(),
            percentage_discount=10,
            created_by=self.instructor,
            expiration_date=datetime.datetime.now(pytz.UTC) + datetime.timedelta(days=2),
        )
        coupon.save()
        # URL for edit_coupon_info
        edit_url = reverse("get_coupon_info", kwargs={"course_id": self.course.id.to_deprecated_string()})
        response = self.client.post(edit_url, {"id": coupon.id})
        self.assertTrue(
            "coupon with the coupon id ({coupon_id}) updated successfully".format(coupon_id=coupon.id)
            in response.content
        )
        self.assertIn(coupon.display_expiry_date, response.content)

        response = self.client.post(edit_url, {"id": 444444})
        self.assertTrue(
            "coupon with the coupon id ({coupon_id}) DoesNotExist".format(coupon_id=444444) in response.content
        )

        response = self.client.post(edit_url, {"id": ""})
        self.assertTrue('coupon id not found"' in response.content)

        coupon.is_active = False
        coupon.save()

        response = self.client.post(edit_url, {"id": coupon.id})
        self.assertTrue(
            "coupon with the coupon id ({coupon_id}) is already inactive".format(coupon_id=coupon.id)
            in response.content
        )
开发者ID:dmohrC,项目名称:edx-platform,代码行数:40,代码来源:test_ecommerce.py

示例4: test_get_coupon_info

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import is_active [as 别名]
    def test_get_coupon_info(self):
        """
        Test Edit Coupon Info Scenarios. Handle all the HttpResponses return by edit_coupon_info view
        """
        coupon = Coupon(
            code='AS452', description='asdsadsa', course_id=text_type(self.course.id),
            percentage_discount=10, created_by=self.instructor,
            expiration_date=datetime.datetime.now(pytz.UTC) + datetime.timedelta(days=2)
        )
        coupon.save()
        # URL for edit_coupon_info
        edit_url = reverse('get_coupon_info', kwargs={'course_id': text_type(self.course.id)})
        response = self.client.post(edit_url, {'id': coupon.id})
        self.assertIn(
            'coupon with the coupon id ({coupon_id}) updated successfully'.format(coupon_id=coupon.id),
            response.content
        )
        self.assertIn(coupon.display_expiry_date, response.content)

        response = self.client.post(edit_url, {'id': 444444})
        self.assertIn(
            'coupon with the coupon id ({coupon_id}) DoesNotExist'.format(coupon_id=444444),
            response.content
        )

        response = self.client.post(edit_url, {'id': ''})
        self.assertIn('coupon id not found"', response.content)

        coupon.is_active = False
        coupon.save()

        response = self.client.post(edit_url, {'id': coupon.id})
        self.assertIn(
            "coupon with the coupon id ({coupon_id}) is already inactive".format(coupon_id=coupon.id),
            response.content
        )
开发者ID:EDUlib,项目名称:edx-platform,代码行数:38,代码来源:test_ecommerce.py


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