Exemplo n.º 1
0
    def test_mode_change_after_refund_seat(self, course_modes, new_mode):
        """
        Test if a course seat is refunded student is enrolled into default course mode
        unless no default mode available.
        """
        course_id = CourseLocator('test_org', 'test_course_number', 'test_run')
        CourseMode.objects.all().delete()
        for course_mode in course_modes:
            CourseModeFactory.create(
                course_id=course_id,
                mode_slug=course_mode,
                mode_display_name=course_mode,
            )

        httpretty.register_uri(httpretty.POST,
                               settings.ECOMMERCE_API_URL + 'refunds/',
                               status=201,
                               body='[1]',
                               content_type='application/json')
        httpretty.register_uri(httpretty.PUT,
                               settings.ECOMMERCE_API_URL +
                               'refunds/1/process/',
                               status=200,
                               body=json.dumps({
                                   "id": 9,
                                   "created": "2017-12-21T18:23:49.468298Z",
                                   "modified": "2017-12-21T18:24:02.741426Z",
                                   "total_credit_excl_tax": "100.00",
                                   "currency": "USD",
                                   "status": "Complete",
                                   "order": 15,
                                   "user": 5
                               }),
                               content_type='application/json')
        enrollment = CourseEnrollment.enroll(self.user,
                                             course_id,
                                             mode=course_modes[0])

        refund_success = refund_seat(enrollment, True)

        enrollment = CourseEnrollment.get_or_create_enrollment(
            self.user, course_id)

        assert refund_success
        self.assertEqual(enrollment.mode, new_mode)
Exemplo n.º 2
0
    def test_mode_change_after_refund_seat(self, course_modes, new_mode):
        """
        Test if a course seat is refunded student is enrolled into default course mode
        unless no default mode available.
        """
        course_id = CourseLocator('test_org', 'test_course_number', 'test_run')
        CourseMode.objects.all().delete()
        for course_mode in course_modes:
            CourseModeFactory.create(
                course_id=course_id,
                mode_slug=course_mode,
                mode_display_name=course_mode,
            )

        httpretty.register_uri(
            httpretty.POST,
            settings.ECOMMERCE_API_URL + 'refunds/',
            status=201,
            body='[1]',
            content_type='application/json'
        )
        httpretty.register_uri(
            httpretty.PUT,
            settings.ECOMMERCE_API_URL + 'refunds/1/process/',
            status=200,
            body=json.dumps({
                "id": 9,
                "created": "2017-12-21T18:23:49.468298Z",
                "modified": "2017-12-21T18:24:02.741426Z",
                "total_credit_excl_tax": "100.00",
                "currency": "USD",
                "status": "Complete",
                "order": 15,
                "user": 5
            }),
            content_type='application/json'
        )
        enrollment = CourseEnrollment.enroll(self.user, course_id, mode=course_modes[0])

        refund_success = refund_seat(enrollment, True)

        enrollment = CourseEnrollment.get_or_create_enrollment(self.user, course_id)

        assert refund_success
        self.assertEqual(enrollment.mode, new_mode)