From bbad9ae772a26621a892f2bf6bf3e159819d721c Mon Sep 17 00:00:00 2001 From: wajeeha-khalid Date: Mon, 14 Sep 2015 11:43:21 +0500 Subject: [PATCH] MA-1182 - added test for not enrolled in course, removed commented out nose test code, formatted import statements according to edx standards --- lms/djangoapps/discussion_api/tests/test_api.py | 6 ++++++ lms/djangoapps/discussion_api/tests/test_views.py | 2 -- lms/djangoapps/discussion_api/views.py | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/discussion_api/tests/test_api.py b/lms/djangoapps/discussion_api/tests/test_api.py index 525e19cdba..baf5441900 100644 --- a/lms/djangoapps/discussion_api/tests/test_api.py +++ b/lms/djangoapps/discussion_api/tests/test_api.py @@ -2912,6 +2912,12 @@ class RetrieveThreadTest( self.assertEqual(get_thread(self.request, self.thread_id), expected_response_data) self.assertEqual(httpretty.last_request().method, "GET") + def test_not_enrolled_in_course(self): + self.register_thread() + self.request.user = UserFactory.create() + with self.assertRaises(Http404): + get_thread(self.request, self.thread_id) + @ddt.data( *itertools.product( [ diff --git a/lms/djangoapps/discussion_api/tests/test_views.py b/lms/djangoapps/discussion_api/tests/test_views.py index 3046233734..960ce4f638 100644 --- a/lms/djangoapps/discussion_api/tests/test_views.py +++ b/lms/djangoapps/discussion_api/tests/test_views.py @@ -588,7 +588,6 @@ class ThreadViewSetDeleteTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): self.thread_id = "test_thread" def test_basic(self): - #from nose.tools import set_trace;set_trace() self.register_get_user_response(self.user) cs_thread = make_minimal_cs_thread({ "id": self.thread_id, @@ -608,7 +607,6 @@ class ThreadViewSetDeleteTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): self.assertEqual(httpretty.last_request().method, "DELETE") def test_delete_nonexistent_thread(self): - #from nose.tools import set_trace;set_trace() self.register_get_thread_error_response(self.thread_id, 404) response = self.client.delete(self.url) self.assertEqual(response.status_code, 404) diff --git a/lms/djangoapps/discussion_api/views.py b/lms/djangoapps/discussion_api/views.py index 5881c63444..7e7bc2710a 100644 --- a/lms/djangoapps/discussion_api/views.py +++ b/lms/djangoapps/discussion_api/views.py @@ -19,10 +19,11 @@ from discussion_api.api import ( get_comment_list, get_course, get_course_topics, + get_thread, get_thread_list, update_comment, update_thread, - get_thread) +) from discussion_api.forms import CommentListGetForm, ThreadListGetForm from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin