{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/27481903","id":27481903,"diff_hunk":"@@ -1640,3 +1647,176 @@ def test_banner_display_off(self):\n         self.client.post(reverse('verify_student_toggle_failed_banner_off'))\n         photo_verification = SoftwareSecurePhotoVerification.objects.get(user=self.user, window=self.window)\n         self.assertFalse(photo_verification.display)\n+\n+\n+class TestInCourseReverifyView(ModuleStoreTestCase):\n+    \"\"\"\n+    Tests for the incourse reverification views.\n+    \"\"\"\n+    IMAGE_DATA = \"abcd,1234\"\n+\n+    def setUp(self):\n+        super(TestInCourseReverifyView, self).setUp()\n+\n+        self.user = UserFactory.create(username=\"rusty\", password=\"test\")\n+        self.client.login(username=\"rusty\", password=\"test\")\n+\n+        self.course_key = SlashSeparatedCourseKey(\"Robot\", \"999\", \"Test_Course\")\n+        CourseFactory.create(org='Robot', number='999', display_name='Test Course')\n+\n+        # Create the course modes\n+        for mode in ('audit', 'honor', 'verified'):\n+            min_price = 0 if mode in [\"honor\", \"audit\"] else 1\n+            CourseModeFactory(mode_slug=mode, course_id=self.course_key, min_price=min_price)\n+\n+        # Enroll the user in the default mode (honor) to emulate\n+        CourseEnrollment.enroll(self.user, self.course_key, mode=\"verified\")\n+        self.config = InCourseReverificationConfiguration(enabled=True)\n+        self.config.save()\n+\n+        # mocking and patching for bi events\n+        analytics_patcher = patch('verify_student.views.analytics')\n+        self.mock_tracker = analytics_patcher.start()\n+        self.addCleanup(analytics_patcher.stop)\n+\n+        self.midterm = \"midterm\"\n+\n+    @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True})\n+    def test_incourse_reverify_feature_flag_get(self):\n+        self.config.enabled = False\n+        self.config.save()\n+        response = self.client.get(self._get_url(self.course_key, self.midterm))\n+        self.assertEquals(response.status_code, 404)\n+\n+    @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True})\n+    def test_incourse_reverify_invalid_course_get(self):\n+        response = self.client.get(self._get_url(\"invalid/course/key\", self.midterm))\n+\n+        self.assertEquals(response.status_code, 404)\n+\n+    @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True})\n+    def test_incourse_reverify_invalid_checkpoint_get(self):\n+        response = self.client.get(self._get_url(self.course_key, \"invalid_checkpoint\"))\n+        self.assertEquals(response.status_code, 404)\n+\n+    @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True})\n+    def test_incourse_reverify_initial_redirect_get(self):\n+        self._create_checkpoint()\n+        response = self.client.get(self._get_url(self.course_key, self.midterm))\n+\n+        url = reverse('verify_student_verify_later',\n+                      kwargs={\"course_id\": unicode(self.course_key)})\n+        self.assertRedirects(response, url)\n+\n+    @override_settings(SEGMENT_IO_LMS_KEY=\"foobar\")\n+    @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True, 'SEGMENT_IO_LMS': True})\n+    def test_incourse_reverify_get(self):\n+        self._create_checkpoint()\n+        self._create_initial_verification()\n+\n+        response = self.client.get(self._get_url(self.course_key, self.midterm))\n+        self.assertEquals(response.status_code, 200)\n+\n+        #Verify Google Analytics event fired after successfully submiting the picture\n+        self.mock_tracker.track.assert_called_once_with(  # pylint: disable=no-member\n+            self.user.id,  # pylint: disable=no-member\n+            EVENT_NAME_USER_ENTERED_INCOURSE_REVERIFY_VIEW,\n+            {\n+                'category': \"verification\",\n+                'label': unicode(self.course_key),\n+                'checkpoint': \"midterm\"\n+            },\n+\n+            context={\n+                'Google Analytics':\n+                {'clientId': None}\n+            }\n+        )\n+        self.mock_tracker.reset_mock()\n+\n+    @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True})\n+    @patch('verify_student.views.render_to_response', render_mock)\n+    def test_invalid_checkpoint_post(self):\n+\n+        response = self.client.post(self._get_url(self.course_key, self.midterm))\n+        self.assertEquals(response.status_code, 200)\n+        ((template, context), _kwargs) = render_mock.call_args  # pylint: disable=unpacking-non-sequence\n+        self.assertIn('incourse_reverify', template)\n+        self.assertTrue(context['error'])\n+\n+    @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True})\n+    def test_incourse_reverify_initial_redirect_post(self):\n+        self._create_checkpoint()\n+\n+        response = self.client.post(self._get_url(self.course_key, self.midterm))\n+        url = reverse('verify_student_verify_later',\n+                      kwargs={\"course_id\": unicode(self.course_key)})\n+\n+        self.assertRedirects(response, url)\n+\n+    @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True})\n+    def test_incourse_reverify_index_error_post(self):\n+        self._create_checkpoint()\n+        self._create_initial_verification()\n+\n+        response = self.client.post(self._get_url(self.course_key, self.midterm), {\"face_image\": \"\"})\n+        self.assertEqual(response.status_code, 400)\n+\n+    @override_settings(SEGMENT_IO_LMS_KEY=\"foobar\")\n+    @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True, 'SEGMENT_IO_LMS': True})\n+    def test_incourse_reverify_post(self):\n+        self._create_checkpoint()\n+        self._create_initial_verification()\n+\n+        response = self.client.post(self._get_url(self.course_key, self.midterm), {\"face_image\": self.IMAGE_DATA})\n+        self.assertEqual(response.status_code, 200)\n+\n+        #Verify Google Analytics event fired after successfully submiting the picture\n+        self.mock_tracker.track.assert_called_once_with(  # pylint: disable=no-member\n+            self.user.id,  # pylint: disable=no-member\n+            EVENT_NAME_USER_SUBMITTED_INCOURSE_REVERIFY,\n+            {\n+                'category': \"verification\",\n+                'label': unicode(self.course_key),\n+                'checkpoint': \"midterm\"","path":"lms/djangoapps/verify_student/tests/test_views.py","position":160,"original_position":160,"commit_id":"d1dea54699485ee1cf15dc20c40dd892dd78d0d9","original_commit_id":"d1dea54699485ee1cf15dc20c40dd892dd78d0d9","user":{"login":"rlucioni","id":969289,"avatar_url":"https://avatars.githubusercontent.com/u/969289?v=3","gravatar_id":"","url":"https://api.github.com/users/rlucioni","html_url":"https://github.com/rlucioni","followers_url":"https://api.github.com/users/rlucioni/followers","following_url":"https://api.github.com/users/rlucioni/following{/other_user}","gists_url":"https://api.github.com/users/rlucioni/gists{/gist_id}","starred_url":"https://api.github.com/users/rlucioni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlucioni/subscriptions","organizations_url":"https://api.github.com/users/rlucioni/orgs","repos_url":"https://api.github.com/users/rlucioni/repos","events_url":"https://api.github.com/users/rlucioni/events{/privacy}","received_events_url":"https://api.github.com/users/rlucioni/received_events","type":"User","site_admin":false},"body":"You can use `self.midterm` here.","created_at":"2015-03-31T14:10:24Z","updated_at":"2015-03-31T14:10:24Z","html_url":"https://github.com/edx/edx-platform/pull/7406#discussion_r27481903","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/7406","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/27481903"},"html":{"href":"https://github.com/edx/edx-platform/pull/7406#discussion_r27481903"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7406"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/7406","id":31428681,"html_url":"https://github.com/edx/edx-platform/pull/7406","diff_url":"https://github.com/edx/edx-platform/pull/7406.diff","patch_url":"https://github.com/edx/edx-platform/pull/7406.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/7406","number":7406,"state":"open","locked":false,"title":"Aamir khan/ecom 1205 ability to reverify","user":{"login":"aamir-khan","id":2344763,"avatar_url":"https://avatars.githubusercontent.com/u/2344763?v=3","gravatar_id":"","url":"https://api.github.com/users/aamir-khan","html_url":"https://github.com/aamir-khan","followers_url":"https://api.github.com/users/aamir-khan/followers","following_url":"https://api.github.com/users/aamir-khan/following{/other_user}","gists_url":"https://api.github.com/users/aamir-khan/gists{/gist_id}","starred_url":"https://api.github.com/users/aamir-khan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aamir-khan/subscriptions","organizations_url":"https://api.github.com/users/aamir-khan/orgs","repos_url":"https://api.github.com/users/aamir-khan/repos","events_url":"https://api.github.com/users/aamir-khan/events{/privacy}","received_events_url":"https://api.github.com/users/aamir-khan/received_events","type":"User","site_admin":false},"body":"WIP @wedaly please review this initial work specially the data models and their relations.","created_at":"2015-03-18T13:34:28Z","updated_at":"2015-03-31T14:10:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac6e931ad7f730d272c6423bfbbd7783a256de31","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/7406/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/7406/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/7406/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/d1dea54699485ee1cf15dc20c40dd892dd78d0d9","head":{"label":"edx:aamir-khan/ECOM-1205-ability-to-reverify","ref":"aamir-khan/ECOM-1205-ability-to-reverify","sha":"d1dea54699485ee1cf15dc20c40dd892dd78d0d9","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"Open edX, the edX platform that powers http://edx.org","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-03-31T10:36:27Z","pushed_at":"2015-03-31T13:56:03Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://openedx.org/","size":1842825,"stargazers_count":1831,"watchers_count":1831,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1032,"mirror_url":null,"open_issues_count":138,"forks":1032,"open_issues":138,"watchers":1831,"default_branch":"master"}},"base":{"label":"edx:aamir-khan/ECOM-912-in-course-reverification","ref":"aamir-khan/ECOM-912-in-course-reverification","sha":"51421311b267143a6c2a6b75002149b78dc13890","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"Open edX, the edX platform that powers http://edx.org","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-03-31T10:36:27Z","pushed_at":"2015-03-31T13:56:03Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://openedx.org/","size":1842825,"stargazers_count":1831,"watchers_count":1831,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1032,"mirror_url":null,"open_issues_count":138,"forks":1032,"open_issues":138,"watchers":1831,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7406"},"html":{"href":"https://github.com/edx/edx-platform/pull/7406"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/7406"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/7406/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7406/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7406/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/d1dea54699485ee1cf15dc20c40dd892dd78d0d9"}}}}