From 3c48585c8e9fceeaef95c5b706f927e880cb2363 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 12 Jun 2015 22:19:01 -0400 Subject: [PATCH] Fix bug in discussion API comment update This bug caused any attempt to update a comment with a non-null parent_id to result in a 500 error without applying the update. The bug was introduced in commit 2c7590d197. --- lms/djangoapps/discussion_api/api.py | 6 +----- lms/djangoapps/discussion_api/tests/test_api.py | 7 ++++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lms/djangoapps/discussion_api/api.py b/lms/djangoapps/discussion_api/api.py index a14bcae278..2b4c7e9bbc 100644 --- a/lms/djangoapps/discussion_api/api.py +++ b/lms/djangoapps/discussion_api/api.py @@ -85,11 +85,7 @@ def _get_comment_and_context(request, comment_id): """ try: cc_comment = Comment(id=comment_id).retrieve() - _, context = _get_thread_and_context( - request, - cc_comment["thread_id"], - cc_comment["parent_id"] - ) + _, context = _get_thread_and_context(request, cc_comment["thread_id"]) return cc_comment, context except CommentClientRequestError: raise Http404 diff --git a/lms/djangoapps/discussion_api/tests/test_api.py b/lms/djangoapps/discussion_api/tests/test_api.py index be157a4273..663e02824a 100644 --- a/lms/djangoapps/discussion_api/tests/test_api.py +++ b/lms/djangoapps/discussion_api/tests/test_api.py @@ -1689,13 +1689,14 @@ class UpdateCommentTest(CommentsServiceMockMixin, UrlResetMixin, ModuleStoreTest for request in httpretty.httpretty.latest_requests: self.assertEqual(request.method, "GET") - def test_basic(self): - self.register_comment() + @ddt.data(None, "test_parent") + def test_basic(self, parent_id): + self.register_comment({"parent_id": parent_id}) actual = update_comment(self.request, "test_comment", {"raw_body": "Edited body"}) expected = { "id": "test_comment", "thread_id": "test_thread", - "parent_id": None, # TODO: we can't get this without retrieving from the thread :-( + "parent_id": parent_id, "author": self.user.username, "author_label": None, "created_at": "2015-06-03T00:00:00Z",