{"action":"created","comment":{"url":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/comments/35161243","id":35161243,"diff_hunk":"@@ -0,0 +1,247 @@\n+\"\"\"Tests OLIAnalyticsBackend: Transmit events to the OLI analytics service\"\"\"\n+from __future__ import absolute_import\n+\n+from mock import patch, Mock\n+\n+from django.test import TestCase\n+from south.utils import datetime_utils as datetime\n+\n+from track.backends.oli import OLIAnalyticsBackend\n+from student.tests.factories import UserFactory\n+\n+\n+# pylint: disable=line-too-long\n+class TestOLIBackend(TestCase):\n+    \"\"\"\n+    Tests OLIAnalyticsBackend.  OLI should only process 'problem_check' event type.\n+    Course IDs must be part of the whitelisted set\n+    \"\"\"\n+    def setUp(self):\n+        self.patcher = patch('track.backends.oli.OAuth1Session.put', mock_put)\n+        self.addCleanup(self.patcher.stop)\n+        self.patcher.start()\n+        self.backend = OLIAnalyticsBackend()\n+\n+        # create a test user\n+        self.user = UserFactory.create()\n+        self.user.save()\n+\n+        # initialize attributes for the test cases.\n+        self.backend.url = 'https://example.com'\n+        self.backend.path = 'path'\n+        self.backend.key = 'key'\n+        self.backend.secret = 'secret'\n+        self.backend.course_id_set = ['edX/DemoX/Demo_Course', 'edX/DemoX/Demo_Course1']\n+\n+    def test_oli_backend_correct_event_type(self):\n+\n+        # OLI only cares about events with event_type = 'problem_check'\n+        # This is a sample problem_check event\n+\n+        event = {\n+            'username': 'verified',\n+            'event_type': 'problem_check',\n+            'ip': '10.0.2.2',\n+            'agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',\n+            'host': 'precise64',\n+            'referer': 'http://localhost:8000/courses/edX/DemoX/Demo_Course/courseware/interactive_demonstrations/basic_questions/',","path":"common/djangoapps/track/backends/tests/test_oli.py","position":47,"original_position":47,"commit_id":"6f368d457bc644545015fff8bc1e52deffcda74c","original_commit_id":"6f368d457bc644545015fff8bc1e52deffcda74c","user":{"login":"stvstnfrd","id":7300975,"avatar_url":"https://avatars.githubusercontent.com/u/7300975?v=3","gravatar_id":"","url":"https://api.github.com/users/stvstnfrd","html_url":"https://github.com/stvstnfrd","followers_url":"https://api.github.com/users/stvstnfrd/followers","following_url":"https://api.github.com/users/stvstnfrd/following{/other_user}","gists_url":"https://api.github.com/users/stvstnfrd/gists{/gist_id}","starred_url":"https://api.github.com/users/stvstnfrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stvstnfrd/subscriptions","organizations_url":"https://api.github.com/users/stvstnfrd/orgs","repos_url":"https://api.github.com/users/stvstnfrd/repos","events_url":"https://api.github.com/users/stvstnfrd/events{/privacy}","received_events_url":"https://api.github.com/users/stvstnfrd/received_events","type":"User","site_admin":false},"body":"Should this referrer URL instead be generated from `settings.SITE_NAME` instead of hard-coding the host and port?","created_at":"2015-07-21T22:14:53Z","updated_at":"2015-07-21T22:14:53Z","html_url":"https://github.com/Stanford-Online/edx-platform/pull/306#discussion_r35161243","pull_request_url":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/306","_links":{"self":{"href":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/comments/35161243"},"html":{"href":"https://github.com/Stanford-Online/edx-platform/pull/306#discussion_r35161243"},"pull_request":{"href":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/306"}}},"pull_request":{"url":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/306","id":36676022,"html_url":"https://github.com/Stanford-Online/edx-platform/pull/306","diff_url":"https://github.com/Stanford-Online/edx-platform/pull/306.diff","patch_url":"https://github.com/Stanford-Online/edx-platform/pull/306.patch","issue_url":"https://api.github.com/repos/Stanford-Online/edx-platform/issues/306","number":306,"state":"open","locked":false,"title":"Lydial/oli event handling","user":{"login":"lydiali","id":4624723,"avatar_url":"https://avatars.githubusercontent.com/u/4624723?v=3","gravatar_id":"","url":"https://api.github.com/users/lydiali","html_url":"https://github.com/lydiali","followers_url":"https://api.github.com/users/lydiali/followers","following_url":"https://api.github.com/users/lydiali/following{/other_user}","gists_url":"https://api.github.com/users/lydiali/gists{/gist_id}","starred_url":"https://api.github.com/users/lydiali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lydiali/subscriptions","organizations_url":"https://api.github.com/users/lydiali/orgs","repos_url":"https://api.github.com/users/lydiali/repos","events_url":"https://api.github.com/users/lydiali/events{/privacy}","received_events_url":"https://api.github.com/users/lydiali/received_events","type":"User","site_admin":false},"body":"@caijim \r\n\r\nNot ready to merge to master yet.  Need to wait till after our post-birch merge release is out.  Also need to wait for other parts of OLI project are done. \r\n\r\n","created_at":"2015-06-01T22:04:30Z","updated_at":"2015-07-21T22:14:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5d6b086552a8fda7e0dc1b9dbc2f6f1c4ef91645","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/306/commits","review_comments_url":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/306/comments","review_comment_url":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Stanford-Online/edx-platform/issues/306/comments","statuses_url":"https://api.github.com/repos/Stanford-Online/edx-platform/statuses/6f368d457bc644545015fff8bc1e52deffcda74c","head":{"label":"Stanford-Online:lydial/oli_event_handling","ref":"lydial/oli_event_handling","sha":"6f368d457bc644545015fff8bc1e52deffcda74c","user":{"login":"Stanford-Online","id":2159497,"avatar_url":"https://avatars.githubusercontent.com/u/2159497?v=3","gravatar_id":"","url":"https://api.github.com/users/Stanford-Online","html_url":"https://github.com/Stanford-Online","followers_url":"https://api.github.com/users/Stanford-Online/followers","following_url":"https://api.github.com/users/Stanford-Online/following{/other_user}","gists_url":"https://api.github.com/users/Stanford-Online/gists{/gist_id}","starred_url":"https://api.github.com/users/Stanford-Online/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stanford-Online/subscriptions","organizations_url":"https://api.github.com/users/Stanford-Online/orgs","repos_url":"https://api.github.com/users/Stanford-Online/repos","events_url":"https://api.github.com/users/Stanford-Online/events{/privacy}","received_events_url":"https://api.github.com/users/Stanford-Online/received_events","type":"Organization","site_admin":false},"repo":{"id":11616657,"name":"edx-platform","full_name":"Stanford-Online/edx-platform","owner":{"login":"Stanford-Online","id":2159497,"avatar_url":"https://avatars.githubusercontent.com/u/2159497?v=3","gravatar_id":"","url":"https://api.github.com/users/Stanford-Online","html_url":"https://github.com/Stanford-Online","followers_url":"https://api.github.com/users/Stanford-Online/followers","following_url":"https://api.github.com/users/Stanford-Online/following{/other_user}","gists_url":"https://api.github.com/users/Stanford-Online/gists{/gist_id}","starred_url":"https://api.github.com/users/Stanford-Online/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stanford-Online/subscriptions","organizations_url":"https://api.github.com/users/Stanford-Online/orgs","repos_url":"https://api.github.com/users/Stanford-Online/repos","events_url":"https://api.github.com/users/Stanford-Online/events{/privacy}","received_events_url":"https://api.github.com/users/Stanford-Online/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Stanford-Online/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/Stanford-Online/edx-platform","forks_url":"https://api.github.com/repos/Stanford-Online/edx-platform/forks","keys_url":"https://api.github.com/repos/Stanford-Online/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Stanford-Online/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Stanford-Online/edx-platform/teams","hooks_url":"https://api.github.com/repos/Stanford-Online/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/Stanford-Online/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/Stanford-Online/edx-platform/events","assignees_url":"https://api.github.com/repos/Stanford-Online/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/Stanford-Online/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/Stanford-Online/edx-platform/tags","blobs_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Stanford-Online/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/Stanford-Online/edx-platform/languages","stargazers_url":"https://api.github.com/repos/Stanford-Online/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/Stanford-Online/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/Stanford-Online/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/Stanford-Online/edx-platform/subscription","commits_url":"https://api.github.com/repos/Stanford-Online/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/Stanford-Online/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/Stanford-Online/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/Stanford-Online/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/Stanford-Online/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Stanford-Online/edx-platform/merges","archive_url":"https://api.github.com/repos/Stanford-Online/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Stanford-Online/edx-platform/downloads","issues_url":"https://api.github.com/repos/Stanford-Online/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/Stanford-Online/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/Stanford-Online/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Stanford-Online/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/Stanford-Online/edx-platform/releases{/id}","created_at":"2013-07-23T19:05:46Z","updated_at":"2015-07-06T06:09:57Z","pushed_at":"2015-07-21T21:19:27Z","git_url":"git://github.com/Stanford-Online/edx-platform.git","ssh_url":"git@github.com:Stanford-Online/edx-platform.git","clone_url":"https://github.com/Stanford-Online/edx-platform.git","svn_url":"https://github.com/Stanford-Online/edx-platform","homepage":"http://code.edx.org/","size":464467,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":51,"forks":3,"open_issues":51,"watchers":16,"default_branch":"master"}},"base":{"label":"Stanford-Online:master","ref":"master","sha":"1924bcefef523f051bee7a5f5a1e66644765672a","user":{"login":"Stanford-Online","id":2159497,"avatar_url":"https://avatars.githubusercontent.com/u/2159497?v=3","gravatar_id":"","url":"https://api.github.com/users/Stanford-Online","html_url":"https://github.com/Stanford-Online","followers_url":"https://api.github.com/users/Stanford-Online/followers","following_url":"https://api.github.com/users/Stanford-Online/following{/other_user}","gists_url":"https://api.github.com/users/Stanford-Online/gists{/gist_id}","starred_url":"https://api.github.com/users/Stanford-Online/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stanford-Online/subscriptions","organizations_url":"https://api.github.com/users/Stanford-Online/orgs","repos_url":"https://api.github.com/users/Stanford-Online/repos","events_url":"https://api.github.com/users/Stanford-Online/events{/privacy}","received_events_url":"https://api.github.com/users/Stanford-Online/received_events","type":"Organization","site_admin":false},"repo":{"id":11616657,"name":"edx-platform","full_name":"Stanford-Online/edx-platform","owner":{"login":"Stanford-Online","id":2159497,"avatar_url":"https://avatars.githubusercontent.com/u/2159497?v=3","gravatar_id":"","url":"https://api.github.com/users/Stanford-Online","html_url":"https://github.com/Stanford-Online","followers_url":"https://api.github.com/users/Stanford-Online/followers","following_url":"https://api.github.com/users/Stanford-Online/following{/other_user}","gists_url":"https://api.github.com/users/Stanford-Online/gists{/gist_id}","starred_url":"https://api.github.com/users/Stanford-Online/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stanford-Online/subscriptions","organizations_url":"https://api.github.com/users/Stanford-Online/orgs","repos_url":"https://api.github.com/users/Stanford-Online/repos","events_url":"https://api.github.com/users/Stanford-Online/events{/privacy}","received_events_url":"https://api.github.com/users/Stanford-Online/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Stanford-Online/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/Stanford-Online/edx-platform","forks_url":"https://api.github.com/repos/Stanford-Online/edx-platform/forks","keys_url":"https://api.github.com/repos/Stanford-Online/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Stanford-Online/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Stanford-Online/edx-platform/teams","hooks_url":"https://api.github.com/repos/Stanford-Online/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/Stanford-Online/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/Stanford-Online/edx-platform/events","assignees_url":"https://api.github.com/repos/Stanford-Online/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/Stanford-Online/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/Stanford-Online/edx-platform/tags","blobs_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Stanford-Online/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/Stanford-Online/edx-platform/languages","stargazers_url":"https://api.github.com/repos/Stanford-Online/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/Stanford-Online/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/Stanford-Online/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/Stanford-Online/edx-platform/subscription","commits_url":"https://api.github.com/repos/Stanford-Online/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/Stanford-Online/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/Stanford-Online/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/Stanford-Online/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/Stanford-Online/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/Stanford-Online/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Stanford-Online/edx-platform/merges","archive_url":"https://api.github.com/repos/Stanford-Online/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Stanford-Online/edx-platform/downloads","issues_url":"https://api.github.com/repos/Stanford-Online/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/Stanford-Online/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/Stanford-Online/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Stanford-Online/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/Stanford-Online/edx-platform/releases{/id}","created_at":"2013-07-23T19:05:46Z","updated_at":"2015-07-06T06:09:57Z","pushed_at":"2015-07-21T21:19:27Z","git_url":"git://github.com/Stanford-Online/edx-platform.git","ssh_url":"git@github.com:Stanford-Online/edx-platform.git","clone_url":"https://github.com/Stanford-Online/edx-platform.git","svn_url":"https://github.com/Stanford-Online/edx-platform","homepage":"http://code.edx.org/","size":464467,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":51,"forks":3,"open_issues":51,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/306"},"html":{"href":"https://github.com/Stanford-Online/edx-platform/pull/306"},"issue":{"href":"https://api.github.com/repos/Stanford-Online/edx-platform/issues/306"},"comments":{"href":"https://api.github.com/repos/Stanford-Online/edx-platform/issues/306/comments"},"review_comments":{"href":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/306/comments"},"review_comment":{"href":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Stanford-Online/edx-platform/pulls/306/commits"},"statuses":{"href":"https://api.github.com/repos/Stanford-Online/edx-platform/statuses/6f368d457bc644545015fff8bc1e52deffcda74c"}}}}