{"action":"created","comment":{"url":"https://api.github.com/repos/mitodl/lore/pulls/comments/32863078","id":32863078,"diff_hunk":"@@ -0,0 +1,389 @@\n+\"\"\"\n+LORE test case\n+\"\"\"\n+\n+from __future__ import unicode_literals\n+import json\n+\n+from rest_framework.status import (\n+    HTTP_200_OK,\n+    HTTP_201_CREATED,\n+    HTTP_204_NO_CONTENT,\n+)\n+from rest_framework.reverse import reverse\n+\n+from learningresources.tests.base import LoreTestCase\n+\n+API_BASE = '/api/v1/'\n+REPO_BASE = '/api/v1/repositories/'\n+\n+\n+def as_json(resp):\n+    \"\"\"Get JSON from response\"\"\"\n+    return json.loads(resp.content.decode('utf-8'))\n+\n+\n+# pylint: disable=too-many-public-methods, too-many-arguments\n+class RESTTestCase(LoreTestCase):\n+    \"\"\"\n+    REST test case\n+    \"\"\"\n+\n+    # pylint: disable=dangerous-default-value\n+    # Do not mutate these fields!\n+    DEFAULT_REPO_DICT = {\n+        'name': 'name',\n+        'description': 'description',\n+    }\n+    DEFAULT_VOCAB_DICT = {\n+        'name': 'name',\n+        'description': 'description',\n+        'required': True,\n+        'weight': 1000,\n+        'vocabulary_type': 'f',\n+    }\n+    DEFAULT_TERM_DICT = {\n+        'label': 'term label',\n+        'weight': 1000,\n+    }\n+\n+    def assert_options_head(self, url, expected_status):\n+        \"\"\"Assert OPTIONS and HEAD\"\"\"\n+        resp = self.client.options(url)\n+        self.assertEqual(expected_status, resp.status_code)\n+        as_json(resp)\n+        self.assertIn(\"HEAD\", resp['ALLOW'])\n+        self.assertIn(\"OPTIONS\", resp['ALLOW'])\n+        self.assertIn(\"GET\", resp['ALLOW'])\n+\n+        resp = self.client.head(url)\n+        self.assertEqual(expected_status, resp.status_code)\n+\n+    def get_repositories(self, expected_status=HTTP_200_OK,\n+                         skip_options_head_test=False):\n+        \"\"\"Get list of repositories\"\"\"\n+        url = REPO_BASE\n+        if not skip_options_head_test:\n+            self.assert_options_head(url, expected_status=expected_status)\n+        resp = self.client.get(url)\n+        self.assertEqual(expected_status, resp.status_code)\n+        if expected_status == HTTP_200_OK:\n+            return as_json(resp)\n+\n+    def create_repository(self, repo_dict=DEFAULT_REPO_DICT,\n+                          expected_status=HTTP_201_CREATED,\n+                          skip_assert=False):\n+        \"\"\"Helper function to create repository\"\"\"\n+\n+        resp = self.client.post(REPO_BASE, repo_dict)\n+        self.assertEqual(expected_status, resp.status_code)\n+        if expected_status == HTTP_201_CREATED:\n+            result_dict = as_json(resp)\n+            if not skip_assert:\n+                for key, value in repo_dict.items():\n+                    self.assertEqual(value, result_dict[key])\n+\n+            self.assertIn(reverse(\n+                'repository-detail', kwargs={\n+                    'repo_slug': result_dict['slug'],\n+                }\n+            ), resp['Location'])\n+\n+            return result_dict\n+\n+    def patch_repository(self, repo_slug, repo_dict,\n+                         expected_status=HTTP_200_OK, skip_assert=False):\n+        \"\"\"Update a repository\"\"\"\n+        resp = self.client.patch(\n+            '{repo_base}{repo_slug}/'.format(\n+                repo_slug=repo_slug,\n+                repo_base=REPO_BASE,\n+            ),\n+            json.dumps(repo_dict),\n+            content_type='application/json',\n+        )\n+        self.assertEqual(expected_status, resp.status_code)\n+        if expected_status == HTTP_200_OK:\n+            result_dict = as_json(resp)\n+            if not skip_assert:\n+                for key, value in repo_dict.items():\n+                    self.assertEqual(value, result_dict[key])\n+            return result_dict\n+\n+    def put_repository(self, repo_slug, repo_dict,","path":"rest/tests/base.py","position":114,"original_position":113,"commit_id":"329e2bd42a71188dd51f5598d2a485e6fbc9a6b4","original_commit_id":"3c92be532b7510ca96bcbb6180953dac8666682d","user":{"login":"noisecapella","id":863262,"avatar_url":"https://avatars.githubusercontent.com/u/863262?v=3","gravatar_id":"","url":"https://api.github.com/users/noisecapella","html_url":"https://github.com/noisecapella","followers_url":"https://api.github.com/users/noisecapella/followers","following_url":"https://api.github.com/users/noisecapella/following{/other_user}","gists_url":"https://api.github.com/users/noisecapella/gists{/gist_id}","starred_url":"https://api.github.com/users/noisecapella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noisecapella/subscriptions","organizations_url":"https://api.github.com/users/noisecapella/orgs","repos_url":"https://api.github.com/users/noisecapella/repos","events_url":"https://api.github.com/users/noisecapella/events{/privacy}","received_events_url":"https://api.github.com/users/noisecapella/received_events","type":"User","site_admin":false},"body":"It's #132 ","created_at":"2015-06-19T19:51:29Z","updated_at":"2015-06-19T19:51:29Z","html_url":"https://github.com/mitodl/lore/pull/106#discussion_r32863078","pull_request_url":"https://api.github.com/repos/mitodl/lore/pulls/106","_links":{"self":{"href":"https://api.github.com/repos/mitodl/lore/pulls/comments/32863078"},"html":{"href":"https://github.com/mitodl/lore/pull/106#discussion_r32863078"},"pull_request":{"href":"https://api.github.com/repos/mitodl/lore/pulls/106"}}},"pull_request":{"url":"https://api.github.com/repos/mitodl/lore/pulls/106","id":37045973,"html_url":"https://github.com/mitodl/lore/pull/106","diff_url":"https://github.com/mitodl/lore/pull/106.diff","patch_url":"https://github.com/mitodl/lore/pull/106.patch","issue_url":"https://api.github.com/repos/mitodl/lore/issues/106","number":106,"state":"open","locked":false,"title":"Add rest app","user":{"login":"noisecapella","id":863262,"avatar_url":"https://avatars.githubusercontent.com/u/863262?v=3","gravatar_id":"","url":"https://api.github.com/users/noisecapella","html_url":"https://github.com/noisecapella","followers_url":"https://api.github.com/users/noisecapella/followers","following_url":"https://api.github.com/users/noisecapella/following{/other_user}","gists_url":"https://api.github.com/users/noisecapella/gists{/gist_id}","starred_url":"https://api.github.com/users/noisecapella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noisecapella/subscriptions","organizations_url":"https://api.github.com/users/noisecapella/orgs","repos_url":"https://api.github.com/users/noisecapella/repos","events_url":"https://api.github.com/users/noisecapella/events{/privacy}","received_events_url":"https://api.github.com/users/noisecapella/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-05T16:11:26Z","updated_at":"2015-06-19T19:51:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d073d994bdb76d3f10629c225284740abb57378","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mitodl/lore/pulls/106/commits","review_comments_url":"https://api.github.com/repos/mitodl/lore/pulls/106/comments","review_comment_url":"https://api.github.com/repos/mitodl/lore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mitodl/lore/issues/106/comments","statuses_url":"https://api.github.com/repos/mitodl/lore/statuses/329e2bd42a71188dd51f5598d2a485e6fbc9a6b4","head":{"label":"mitodl:feature/gs/rest-api","ref":"feature/gs/rest-api","sha":"329e2bd42a71188dd51f5598d2a485e6fbc9a6b4","user":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"repo":{"id":34909549,"name":"lore","full_name":"mitodl/lore","owner":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitodl/lore","description":"Learning Object Repository for Education","fork":false,"url":"https://api.github.com/repos/mitodl/lore","forks_url":"https://api.github.com/repos/mitodl/lore/forks","keys_url":"https://api.github.com/repos/mitodl/lore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitodl/lore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitodl/lore/teams","hooks_url":"https://api.github.com/repos/mitodl/lore/hooks","issue_events_url":"https://api.github.com/repos/mitodl/lore/issues/events{/number}","events_url":"https://api.github.com/repos/mitodl/lore/events","assignees_url":"https://api.github.com/repos/mitodl/lore/assignees{/user}","branches_url":"https://api.github.com/repos/mitodl/lore/branches{/branch}","tags_url":"https://api.github.com/repos/mitodl/lore/tags","blobs_url":"https://api.github.com/repos/mitodl/lore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitodl/lore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitodl/lore/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitodl/lore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitodl/lore/statuses/{sha}","languages_url":"https://api.github.com/repos/mitodl/lore/languages","stargazers_url":"https://api.github.com/repos/mitodl/lore/stargazers","contributors_url":"https://api.github.com/repos/mitodl/lore/contributors","subscribers_url":"https://api.github.com/repos/mitodl/lore/subscribers","subscription_url":"https://api.github.com/repos/mitodl/lore/subscription","commits_url":"https://api.github.com/repos/mitodl/lore/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitodl/lore/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitodl/lore/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitodl/lore/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitodl/lore/contents/{+path}","compare_url":"https://api.github.com/repos/mitodl/lore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitodl/lore/merges","archive_url":"https://api.github.com/repos/mitodl/lore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitodl/lore/downloads","issues_url":"https://api.github.com/repos/mitodl/lore/issues{/number}","pulls_url":"https://api.github.com/repos/mitodl/lore/pulls{/number}","milestones_url":"https://api.github.com/repos/mitodl/lore/milestones{/number}","notifications_url":"https://api.github.com/repos/mitodl/lore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitodl/lore/labels{/name}","releases_url":"https://api.github.com/repos/mitodl/lore/releases{/id}","created_at":"2015-05-01T15:34:34Z","updated_at":"2015-06-17T02:41:03Z","pushed_at":"2015-06-19T19:14:51Z","git_url":"git://github.com/mitodl/lore.git","ssh_url":"git@github.com:mitodl/lore.git","clone_url":"https://github.com/mitodl/lore.git","svn_url":"https://github.com/mitodl/lore","homepage":"https://goo.gl/nDVx4D","size":5138,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":53,"forks":2,"open_issues":53,"watchers":6,"default_branch":"master"}},"base":{"label":"mitodl:master","ref":"master","sha":"76a109915a2a5c906829f979b39cde9ce0f02956","user":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"repo":{"id":34909549,"name":"lore","full_name":"mitodl/lore","owner":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitodl/lore","description":"Learning Object Repository for Education","fork":false,"url":"https://api.github.com/repos/mitodl/lore","forks_url":"https://api.github.com/repos/mitodl/lore/forks","keys_url":"https://api.github.com/repos/mitodl/lore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitodl/lore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitodl/lore/teams","hooks_url":"https://api.github.com/repos/mitodl/lore/hooks","issue_events_url":"https://api.github.com/repos/mitodl/lore/issues/events{/number}","events_url":"https://api.github.com/repos/mitodl/lore/events","assignees_url":"https://api.github.com/repos/mitodl/lore/assignees{/user}","branches_url":"https://api.github.com/repos/mitodl/lore/branches{/branch}","tags_url":"https://api.github.com/repos/mitodl/lore/tags","blobs_url":"https://api.github.com/repos/mitodl/lore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitodl/lore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitodl/lore/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitodl/lore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitodl/lore/statuses/{sha}","languages_url":"https://api.github.com/repos/mitodl/lore/languages","stargazers_url":"https://api.github.com/repos/mitodl/lore/stargazers","contributors_url":"https://api.github.com/repos/mitodl/lore/contributors","subscribers_url":"https://api.github.com/repos/mitodl/lore/subscribers","subscription_url":"https://api.github.com/repos/mitodl/lore/subscription","commits_url":"https://api.github.com/repos/mitodl/lore/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitodl/lore/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitodl/lore/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitodl/lore/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitodl/lore/contents/{+path}","compare_url":"https://api.github.com/repos/mitodl/lore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitodl/lore/merges","archive_url":"https://api.github.com/repos/mitodl/lore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitodl/lore/downloads","issues_url":"https://api.github.com/repos/mitodl/lore/issues{/number}","pulls_url":"https://api.github.com/repos/mitodl/lore/pulls{/number}","milestones_url":"https://api.github.com/repos/mitodl/lore/milestones{/number}","notifications_url":"https://api.github.com/repos/mitodl/lore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitodl/lore/labels{/name}","releases_url":"https://api.github.com/repos/mitodl/lore/releases{/id}","created_at":"2015-05-01T15:34:34Z","updated_at":"2015-06-17T02:41:03Z","pushed_at":"2015-06-19T19:14:51Z","git_url":"git://github.com/mitodl/lore.git","ssh_url":"git@github.com:mitodl/lore.git","clone_url":"https://github.com/mitodl/lore.git","svn_url":"https://github.com/mitodl/lore","homepage":"https://goo.gl/nDVx4D","size":5138,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":53,"forks":2,"open_issues":53,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mitodl/lore/pulls/106"},"html":{"href":"https://github.com/mitodl/lore/pull/106"},"issue":{"href":"https://api.github.com/repos/mitodl/lore/issues/106"},"comments":{"href":"https://api.github.com/repos/mitodl/lore/issues/106/comments"},"review_comments":{"href":"https://api.github.com/repos/mitodl/lore/pulls/106/comments"},"review_comment":{"href":"https://api.github.com/repos/mitodl/lore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mitodl/lore/pulls/106/commits"},"statuses":{"href":"https://api.github.com/repos/mitodl/lore/statuses/329e2bd42a71188dd51f5598d2a485e6fbc9a6b4"}}}}