From c2ecaa7e3028e2e266ac1185621ae097bfa9261e Mon Sep 17 00:00:00 2001 From: Waqas Khalid Date: Mon, 29 Sep 2014 19:22:58 +0500 Subject: [PATCH] Forum shouldn't cuase error while searching unicode If we use unicode character in the search of forum it will cuase the error which is not the desired behavior it should check and return result. TNL-336 --- .../django_comment_client/forum/tests.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lms/djangoapps/django_comment_client/forum/tests.py b/lms/djangoapps/django_comment_client/forum/tests.py index 518cbfc8a0..1f1dfcdd56 100644 --- a/lms/djangoapps/django_comment_client/forum/tests.py +++ b/lms/djangoapps/django_comment_client/forum/tests.py @@ -898,6 +898,29 @@ class ForumFormDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin): self.assertEqual(response_data["discussion_data"][0]["title"], text) self.assertEqual(response_data["discussion_data"][0]["body"], text) +@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) +class ForumDiscussionSearchUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin): + def setUp(self): + self.course = CourseFactory.create() + self.student = UserFactory.create() + CourseEnrollmentFactory(user=self.student, course_id=self.course.id) + + @patch('lms.lib.comment_client.utils.requests.request') + def _test_unicode_data(self, text, mock_request): + mock_request.side_effect = make_mock_request_impl(text) + data = { + "ajax": 1, + "text": text, + } + request = RequestFactory().get("dummy_url", data) + request.user = self.student + request.META["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest" # so request.is_ajax() == True + + response = views.forum_form_discussion(request, self.course.id.to_deprecated_string()) + self.assertEqual(response.status_code, 200) + response_data = json.loads(response.content) + self.assertEqual(response_data["discussion_data"][0]["title"], text) + self.assertEqual(response_data["discussion_data"][0]["body"], text) @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) class SingleThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):