{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/31906195","id":31906195,"diff_hunk":"@@ -1579,3 +1583,130 @@ def test_invalid_field(self):\n             assertion.exception.message_dict,\n             {\"raw_body\": [\"This field is required.\"]}\n         )\n+\n+\n+@ddt.ddt\n+class DeleteThreadTest(CommentsServiceMockMixin, UrlResetMixin, ModuleStoreTestCase):\n+    \"\"\"Tests for delete_thread\"\"\"\n+    @mock.patch.dict(\"django.conf.settings.FEATURES\", {\"ENABLE_DISCUSSION_SERVICE\": True})\n+    def setUp(self):\n+        super(DeleteThreadTest, self).setUp()\n+        httpretty.reset()\n+        httpretty.enable()\n+        self.addCleanup(httpretty.disable)\n+        self.user = UserFactory.create()\n+        self.register_get_user_response(self.user)\n+        self.request = RequestFactory().get(\"/test_path\")\n+        self.request.user = self.user\n+        self.course = CourseFactory.create()\n+        self.thread_id = \"test_thread\"\n+        CourseEnrollmentFactory.create(user=self.user, course_id=self.course.id)\n+\n+    def register_thread(self, overrides=None):\n+        \"\"\"\n+        Make a thread with appropriate data overridden by the overrides\n+        parameter and register mock responses for both GET and DELETE on its\n+        endpoint.\n+        \"\"\"\n+        cs_data = make_minimal_cs_thread({\n+            \"id\": self.thread_id,\n+            \"course_id\": unicode(self.course.id),\n+            \"user_id\": str(self.user.id),\n+        })\n+        cs_data.update(overrides or {})\n+        self.register_get_thread_response(cs_data)\n+        self.register_delete_thread_response(cs_data[\"id\"])\n+\n+    def test_basic(self):\n+        self.register_thread()\n+        self.assertIsNone(delete_thread(self.request, self.thread_id))\n+        self.assertEqual(\n+            urlparse(httpretty.last_request().path).path,\n+            \"/api/v1/threads/{}\".format(self.thread_id)\n+        )\n+        self.assertEqual(httpretty.last_request().method, \"DELETE\")\n+\n+    def test_thread_id_not_found(self):\n+        self.register_get_thread_error_response(\"missing_thread\", 404)\n+        with self.assertRaises(Http404):\n+            delete_thread(self.request, \"missing_thread\")\n+\n+    def test_nonexistent_course(self):\n+        self.register_thread({\"course_id\": \"not_a_real_course\"})","path":"lms/djangoapps/discussion_api/tests/test_api.py","position":79,"original_position":79,"commit_id":"e8ae304b04c1e0c4238d43d7ab1a3f7ab46c442e","original_commit_id":"e8ae304b04c1e0c4238d43d7ab1a3f7ab46c442e","user":{"login":"gwprice","id":4027165,"avatar_url":"https://avatars.githubusercontent.com/u/4027165?v=3","gravatar_id":"","url":"https://api.github.com/users/gwprice","html_url":"https://github.com/gwprice","followers_url":"https://api.github.com/users/gwprice/followers","following_url":"https://api.github.com/users/gwprice/following{/other_user}","gists_url":"https://api.github.com/users/gwprice/gists{/gist_id}","starred_url":"https://api.github.com/users/gwprice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwprice/subscriptions","organizations_url":"https://api.github.com/users/gwprice/orgs","repos_url":"https://api.github.com/users/gwprice/repos","events_url":"https://api.github.com/users/gwprice/events{/privacy}","received_events_url":"https://api.github.com/users/gwprice/received_events","type":"User","site_admin":false},"body":"This should use a valid key","created_at":"2015-06-08T11:43:58Z","updated_at":"2015-06-08T11:43:58Z","html_url":"https://github.com/edx/edx-platform/pull/8355#discussion_r31906195","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/8355","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/31906195"},"html":{"href":"https://github.com/edx/edx-platform/pull/8355#discussion_r31906195"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8355"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/8355","id":36885039,"html_url":"https://github.com/edx/edx-platform/pull/8355","diff_url":"https://github.com/edx/edx-platform/pull/8355.diff","patch_url":"https://github.com/edx/edx-platform/pull/8355.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/8355","number":8355,"state":"open","locked":false,"title":"MA-661: Clee/discussion api delete thread","user":{"login":"BenjiLee","id":7101723,"avatar_url":"https://avatars.githubusercontent.com/u/7101723?v=3","gravatar_id":"","url":"https://api.github.com/users/BenjiLee","html_url":"https://github.com/BenjiLee","followers_url":"https://api.github.com/users/BenjiLee/followers","following_url":"https://api.github.com/users/BenjiLee/following{/other_user}","gists_url":"https://api.github.com/users/BenjiLee/gists{/gist_id}","starred_url":"https://api.github.com/users/BenjiLee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenjiLee/subscriptions","organizations_url":"https://api.github.com/users/BenjiLee/orgs","repos_url":"https://api.github.com/users/BenjiLee/repos","events_url":"https://api.github.com/users/BenjiLee/events{/privacy}","received_events_url":"https://api.github.com/users/BenjiLee/received_events","type":"User","site_admin":false},"body":"@gwprice @jimabramson \r\nFYI @cahrens ","created_at":"2015-06-03T22:27:45Z","updated_at":"2015-06-08T11:43:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fdba74390776d633cfe19428b28a3c137c4b6223","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/8355/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/8355/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/8355/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/e8ae304b04c1e0c4238d43d7ab1a3f7ab46c442e","head":{"label":"edx:clee/discussion_api_delete_thread","ref":"clee/discussion_api_delete_thread","sha":"e8ae304b04c1e0c4238d43d7ab1a3f7ab46c442e","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-06-06T23:11:50Z","pushed_at":"2015-06-08T11:42:34Z","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":1907019,"stargazers_count":1964,"watchers_count":1964,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1129,"mirror_url":null,"open_issues_count":179,"forks":1129,"open_issues":179,"watchers":1964,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"82f7238f9dc7cec5fbe131e3ff5ea448921e7ee9","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-06-06T23:11:50Z","pushed_at":"2015-06-08T11:42:34Z","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":1907019,"stargazers_count":1964,"watchers_count":1964,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1129,"mirror_url":null,"open_issues_count":179,"forks":1129,"open_issues":179,"watchers":1964,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8355"},"html":{"href":"https://github.com/edx/edx-platform/pull/8355"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8355"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8355/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8355/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/8355/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/e8ae304b04c1e0c4238d43d7ab1a3f7ab46c442e"}}}}