Esempio n. 1
0
def can_show_streak_discount_experiment_coupon(user, course):
    """
    Check whether this combination of user and course
    can receive the AA-759 experiment discount.
    """
    # Course end date needs to be in the future
    if course.has_ended():
        return False

    # Course needs to have a non-expired verified mode
    modes_dict = CourseMode.modes_for_course_dict(course=course,
                                                  include_expired=False)
    if 'verified' not in modes_dict:
        return False

    # Learner needs to be in an upgradeable mode
    try:
        enrollment = CourseEnrollment.objects.get(
            user=user,
            course=course.id,
        )
    except CourseEnrollment.DoesNotExist:
        return False

    if not is_mode_upsellable(user, enrollment):
        return False

    # We can't import this at Django load time within the openedx tests settings context
    from openedx.features.enterprise_support.utils import is_enterprise_learner
    # Don't give discount to enterprise users
    if is_enterprise_learner(user):
        return False

    return True
Esempio n. 2
0
 def test_is_mode_upsellable(self, mode, is_upsellable):
     """
     Test if this is a mode that is upsellable
     """
     CourseModeFactory.create(mode_slug=mode, course_id=self.course.id)
     if mode == CourseMode.CREDIT_MODE:
         CourseModeFactory.create(mode_slug=CourseMode.VERIFIED,
                                  course_id=self.course.id)
     enrollment = CourseEnrollmentFactory(is_active=True,
                                          mode=mode,
                                          course_id=self.course.id,
                                          user=self.user)
     assert is_mode_upsellable(self.user, enrollment) is is_upsellable