コード例 #1
0
ファイル: test_utils.py プロジェクト: parruc/edx-platform
    def test_student_enrollment_status(self, is_enrolled, enrolled_mode,
                                       is_upgrade_required, mock_get_mode):
        """Verify that program data is supplemented with the student's enrollment status."""
        expected_upgrade_url = '{root}/{path}?sku={sku}'.format(
            root=ECOMMERCE_URL_ROOT,
            path=self.checkout_path.strip('/'),
            sku=self.sku,
        )

        update_commerce_config(enabled=True, checkout_page=self.checkout_path)

        mock_mode = mock.Mock()
        mock_mode.sku = self.sku
        mock_get_mode.return_value = mock_mode

        if is_enrolled:
            CourseEnrollmentFactory(user=self.user,
                                    course_id=self.course.id,
                                    mode=enrolled_mode)

        data = ProgramDataExtender(self.program, self.user).extend()

        self._assert_supplemented(
            data,
            is_enrolled=is_enrolled,
            upgrade_url=expected_upgrade_url if is_upgrade_required else None)
コード例 #2
0
    def test_student_enrollment_status(self, is_enrolled, enrolled_mode, is_upgrade_required, mock_get_mode):
        """
        Verify that program data is supplemented with the student's enrollment status.
        """
        expected_upgrade_url = '{root}/{path}?sku={sku}'.format(
            root=ECOMMERCE_URL_ROOT,
            path=self.checkout_path.strip('/'),
            sku=self.sku,
        )

        update_commerce_config(enabled=True, checkout_page=self.checkout_path)

        mock_mode = mock.Mock()
        mock_mode.sku = self.sku
        mock_get_mode.return_value = mock_mode

        if is_enrolled:
            CourseEnrollmentFactory(user=self.user, course_id=self.course.id, mode=enrolled_mode)  # pylint: disable=no-member

        data = utils.ProgramDataExtender(self.program, self.user).extend()

        self._assert_supplemented(
            data,
            is_enrolled=is_enrolled,
            upgrade_url=expected_upgrade_url if is_upgrade_required else None
        )
コード例 #3
0
ファイル: test_utils.py プロジェクト: moonshot/edx-platform
    def test_inactive_enrollment_no_upgrade(self, enrolled_mode):
        """Verify that a student with an inactive enrollment isn't encouraged to upgrade."""
        update_commerce_config(enabled=True, checkout_page=self.checkout_path)

        CourseEnrollmentFactory(
            user=self.user, course_id=self.course.id, mode=enrolled_mode, is_active=False  # pylint: disable=no-member
        )

        data = utils.supplement_program_data(self.program, self.user)

        self._assert_supplemented(data)
コード例 #4
0
    def test_ecommerce_disabled(self, mock_get_mode):
        """Verify that the utility can operate when the ecommerce service is disabled."""
        update_commerce_config(enabled=False, checkout_page=self.checkout_path)

        mock_mode = mock.Mock()
        mock_mode.sku = self.sku
        mock_get_mode.return_value = mock_mode

        CourseEnrollmentFactory(user=self.user, course_id=self.course.id, mode=MODES.audit)  # pylint: disable=no-member

        data = utils.ProgramDataExtender(self.program, self.user).extend()

        self._assert_supplemented(data, is_enrolled=True, upgrade_url=None)
コード例 #5
0
    def test_inactive_enrollment_no_upgrade(self, enrolled_mode):
        """Verify that a student with an inactive enrollment isn't encouraged to upgrade."""
        update_commerce_config(enabled=True, checkout_page=self.checkout_path)

        CourseEnrollmentFactory(
            user=self.user,
            course_id=self.course.id,  # pylint: disable=no-member
            mode=enrolled_mode,
            is_active=False,
        )

        data = utils.ProgramDataExtender(self.program, self.user).extend()

        self._assert_supplemented(data)
コード例 #6
0
ファイル: test_utils.py プロジェクト: shahbazn/edx-platform
    def test_ecommerce_disabled(self, mock_get_mode):
        """
        Verify that the utility can operate when the ecommerce service is disabled.
        """
        update_commerce_config(enabled=False, checkout_page=self.checkout_path)

        mock_mode = mock.Mock()
        mock_mode.sku = self.sku
        mock_get_mode.return_value = mock_mode

        CourseEnrollmentFactory(user=self.user, course_id=self.course.id, mode=MODES.audit)

        data = ProgramDataExtender(self.program, self.user).extend()

        self._assert_supplemented(data, is_enrolled=True, upgrade_url=None)
コード例 #7
0
ファイル: test_utils.py プロジェクト: dehamzah/edx-platform
    def test_inactive_enrollment_no_upgrade(self, enrolled_mode):
        """
        Verify that a student with an inactive enrollment isn't encouraged to upgrade.
        """
        update_commerce_config(enabled=True, checkout_page=self.checkout_path)

        CourseEnrollmentFactory(
            user=self.user,
            course_id=self.course.id,
            mode=enrolled_mode,
            is_active=False,
        )

        data = ProgramDataExtender(self.program, self.user).extend()

        self._assert_supplemented(data)
コード例 #8
0
 def test_no_id_redirect_otto(self):
     # Create the course modes
     prof_course = CourseFactory.create()
     CourseModeFactory(mode_slug=CourseMode.NO_ID_PROFESSIONAL_MODE, course_id=prof_course.id,
                       min_price=100, sku='TEST', bulk_sku="BULKTEST")
     ecomm_test_utils.update_commerce_config(enabled=True)
     # Enroll the user in the test course
     CourseEnrollmentFactory(
         is_active=False,
         mode=CourseMode.NO_ID_PROFESSIONAL_MODE,
         course_id=prof_course.id,
         user=self.user
     )
     # Configure whether we're upgrading or not
     url = reverse('course_modes_choose', args=[unicode(prof_course.id)])
     response = self.client.get(url)
     self.assertRedirects(response, 'http://testserver/basket/add/?sku=TEST', fetch_redirect_response=False)
     ecomm_test_utils.update_commerce_config(enabled=False)