Commit 23c49ecc by Tim Babych Committed by Oleg Marshev

enable search

parent e7967f31
...@@ -87,12 +87,10 @@ class BaseAnnotationViewTests(APITestCase): ...@@ -87,12 +87,10 @@ class BaseAnnotationViewTests(APITestCase):
""" """
Create annotation Create annotation
""" """
opts = { opts = self.payload.copy()
'user': TEST_USER,
}
opts.update(kwargs) opts.update(kwargs)
url = reverse('api:v1:annotations') url = reverse('api:v1:annotations')
response = self.client.post(url, self.payload, format='json') response = self.client.post(url, opts, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
es.indices.refresh() es.indices.refresh()
return response.data.copy() return response.data.copy()
...@@ -295,21 +293,21 @@ class AnnotationViewTests(BaseAnnotationViewTests): ...@@ -295,21 +293,21 @@ class AnnotationViewTests(BaseAnnotationViewTests):
# response = self.client.delete(url, self.headers) # response = self.client.delete(url, self.headers)
# self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND, "response should be 404 NOT FOUND") # self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND, "response should be 404 NOT FOUND")
# def test_search(self): def test_search(self):
# """ """
# Tests for search method. Tests for search method.
# """ """
# note_1 = self._create_annotation(text=u'First one') note_1 = self._create_annotation(text=u'First one')
# note_2 = self._create_annotation(text=u'Second note') note_2 = self._create_annotation(text=u'Second note')
# note_3 = self._create_annotation(text=u'Third note') note_3 = self._create_annotation(text=u'Third note')
# results = self._get_search_results() results = self._get_search_results()
# self.assertEqual(results['total'], 3) self.assertEqual(results['total'], 3)
# results = self._get_search_results("text=Second") results = self._get_search_results("text=Second")
# self.assertEqual(results['total'], 1) self.assertEqual(results['total'], 1)
# self.assertEqual(len(results['rows']), 1) self.assertEqual(len(results['rows']), 1)
# self.assertEqual(results['rows'][0]['text'], 'Second note') self.assertEqual(results['rows'][0]['text'], 'Second note')
# def test_search_ordering(self): # def test_search_ordering(self):
# """ # """
......
...@@ -25,7 +25,9 @@ class AnnotationSearchView(APIView): ...@@ -25,7 +25,9 @@ class AnnotationSearchView(APIView):
""" """
Search annotations. Search annotations.
""" """
params = self.request.QUERY_PARAMS.dict() params = {}
for k, v in self.request.QUERY_PARAMS.dict().items():
params[k] = v.lower()
results = NoteMappingType.process_result( results = NoteMappingType.process_result(
list(note_searcher.filter(**params).values_dict("_source")) list(note_searcher.filter(**params).values_dict("_source"))
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment