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


Python RegistrationCodeRedemption.save方法代码示例

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


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

示例1: test_course_registration_features

# 需要导入模块: from shoppingcart.models import RegistrationCodeRedemption [as 别名]
# 或者: from shoppingcart.models.RegistrationCodeRedemption import save [as 别名]
    def test_course_registration_features(self):
        query_features = [
            'code', 'redeem_code_url', 'course_id', 'company_name', 'created_by',
            'redeemed_by', 'invoice_id', 'purchaser', 'customer_reference_number', 'internal_reference'
        ]
        order = Order(user=self.instructor, status='purchased')
        order.save()

        registration_code_redemption = RegistrationCodeRedemption(
            registration_code_id=1, redeemed_by=self.instructor
        )
        registration_code_redemption.save()
        registration_codes = CourseRegistrationCode.objects.all()
        course_registration_list = course_registration_features(query_features, registration_codes, csv_type='download')
        self.assertEqual(len(course_registration_list), len(registration_codes))
        for course_registration in course_registration_list:
            self.assertEqual(set(course_registration.keys()), set(query_features))
            self.assertIn(course_registration['code'], [registration_code.code for registration_code in registration_codes])
            self.assertIn(
                course_registration['course_id'],
                [registration_code.course_id.to_deprecated_string() for registration_code in registration_codes]
            )
            self.assertIn(
                course_registration['company_name'],
                [getattr(registration_code.invoice, 'company_name') for registration_code in registration_codes]
            )
            self.assertIn(
                course_registration['invoice_id'],
                [registration_code.invoice_id for registration_code in registration_codes]
            )
开发者ID:alexmerser,项目名称:lms,代码行数:32,代码来源:test_basic.py

示例2: test_regcode_multi_redemptions

# 需要导入模块: from shoppingcart.models import RegistrationCodeRedemption [as 别名]
# 或者: from shoppingcart.models.RegistrationCodeRedemption import save [as 别名]
    def test_regcode_multi_redemptions(self):
        """
        Asserts the data model around RegistrationCodeRedemption and
        what happens when we do multiple redemptions by same user
        """
        self.cart.order_type = 'business'
        self.cart.save()
        CourseRegCodeItem.add_to_order(self.cart, self.course_key, 2)
        self.cart.purchase()

        reg_codes = CourseRegistrationCode.objects.filter(order=self.cart)

        self.assertEqual(len(reg_codes), 2)

        enrollment = CourseEnrollment.enroll(self.user, self.course_key)

        ids = []
        for reg_code in reg_codes:
            redemption = RegistrationCodeRedemption(
                registration_code=reg_code,
                redeemed_by=self.user,
                course_enrollment=enrollment
            )
            redemption.save()
            ids.append(redemption.id)  # pylint: disable=no-member

        test_redemption = RegistrationCodeRedemption.registration_code_used_for_enrollment(enrollment)

        self.assertIn(test_redemption.id, ids)  # pylint: disable=no-member
开发者ID:inares,项目名称:edx-platform,代码行数:31,代码来源:test_models.py

示例3: test_course_registration_features

# 需要导入模块: from shoppingcart.models import RegistrationCodeRedemption [as 别名]
# 或者: from shoppingcart.models.RegistrationCodeRedemption import save [as 别名]
    def test_course_registration_features(self):
        query_features = ['code', 'course_id', 'transaction_group_name', 'created_by', 'redeemed_by']
        for i in range(5):
            course_code = CourseRegistrationCode(
                code="test_code{}".format(i), course_id=self.course_key.to_deprecated_string(),
                transaction_group_name='TestName', created_by=self.users[0]
            )
            course_code.save()

        order = Order(user=self.users[0], status='purchased')
        order.save()

        registration_code_redemption = RegistrationCodeRedemption(
            order=order, registration_code_id=1, redeemed_by=self.users[0]
        )
        registration_code_redemption.save()
        registration_codes = CourseRegistrationCode.objects.all()
        course_registration_list = course_registration_features(query_features, registration_codes, csv_type='download')
        self.assertEqual(len(course_registration_list), len(registration_codes))
        for course_registration in course_registration_list:
            self.assertEqual(set(course_registration.keys()), set(query_features))
            self.assertIn(course_registration['code'], [registration_code.code for registration_code in registration_codes])
            self.assertIn(
                course_registration['course_id'],
                [registration_code.course_id.to_deprecated_string() for registration_code in registration_codes]
            )
            self.assertIn(
                course_registration['transaction_group_name'],
                [registration_code.transaction_group_name for registration_code in registration_codes]
            )
开发者ID:AdityaKashyap,项目名称:edx-platform,代码行数:32,代码来源:test_basic.py

示例4: test_regcode_redemptions

# 需要导入模块: from shoppingcart.models import RegistrationCodeRedemption [as 别名]
# 或者: from shoppingcart.models.RegistrationCodeRedemption import save [as 别名]
    def test_regcode_redemptions(self):
        """
        Asserts the data model around RegistrationCodeRedemption
        """
        self.cart.order_type = 'business'
        self.cart.save()
        CourseRegCodeItem.add_to_order(self.cart, self.course_key, 2)
        self.cart.purchase()

        reg_code = CourseRegistrationCode.objects.filter(order=self.cart)[0]

        enrollment = CourseEnrollment.enroll(self.user, self.course_key)

        redemption = RegistrationCodeRedemption(
            registration_code=reg_code,
            redeemed_by=self.user,
            course_enrollment=enrollment
        )
        redemption.save()

        test_redemption = RegistrationCodeRedemption.registration_code_used_for_enrollment(enrollment)

        self.assertEqual(test_redemption.id, redemption.id)  # pylint: disable=no-member
开发者ID:inares,项目名称:edx-platform,代码行数:25,代码来源:test_models.py


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