Commit 9d9f0c2f by Awais

ECOM-759 if course is none return 404 error code.

parent 708fd87b
......@@ -716,6 +716,14 @@ class TestMidCourseReverifyView(ModuleStoreTestCase):
# enrolled in a verified course, and the window is open
self.assertEquals(response.status_code, 200)
@patch('verify_student.views.render_to_response', render_mock)
def test_midcourse_reverify_invalid_course_id(self):
# if course id is invalid return 400
invalid_course_key = CourseLocator('edx', 'not', 'valid')
url = reverse('verify_student_midcourse_reverify', kwargs={'course_id': unicode(invalid_course_key)})
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
@override_settings(MODULESTORE=MODULESTORE_CONFIG)
class TestReverificationBanner(ModuleStoreTestCase):
......
......@@ -1061,6 +1061,9 @@ class MidCourseReverifyView(View):
"""
course_id = CourseKey.from_string(course_id)
course = modulestore().get_course(course_id)
if course is None:
raise Http404
course_enrollment = CourseEnrollment.get_or_create_enrollment(request.user, course_id)
course_enrollment.update_enrollment(mode="verified")
course_enrollment.emit_event(EVENT_NAME_USER_ENTERED_MIDCOURSE_REVERIFY_VIEW)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment