Commit 782ed102 by Oleg Marshev

Fix tests.

parent 0ef2b13c
...@@ -126,25 +126,25 @@ class AnnotationViewTests(APITestCase): ...@@ -126,25 +126,25 @@ class AnnotationViewTests(APITestCase):
self.assertEqual(annotation_1['name'], 'foo') self.assertEqual(annotation_1['name'], 'foo')
self.assertEqual(annotation_2['name'], 'bar') self.assertEqual(annotation_2['name'], 'bar')
@unittest.skip("TODO") @patch('notesapi.v1.views.Annotation', autospec=Annotation)
@patch('notesapi.v1.views.Annotation') def test_create_refresh(self, mocked_annotation):
def test_create_refresh(self, ann_mock):
""" """
Ensure save was with refresh. Ensure save was with refresh.
""" """
mocked_annotation.return_value.__getitem__ = lambda x, y: 'test_id'
url = reverse('api:v1:annotations') + '?refresh=true' url = reverse('api:v1:annotations') + '?refresh=true'
response = self.client.post(url, {}, format='json', **self.headers) response = self.client.post(url, {}, format='json', **self.headers)
ann_mock.return_value.save.assert_called_once_with(refresh=True) mocked_annotation.return_value.save.assert_called_once_with(refresh=True)
@unittest.skip("TODO") @patch('notesapi.v1.views.Annotation', autospec=Annotation)
@patch('annotator.store.Annotation') def test_create_disable_refresh(self, mocked_annotation):
def test_create_disable_refresh(self, ann_mock):
""" """
Ensure save was without refresh. Ensure save was without refresh.
""" """
mocked_annotation.return_value.__getitem__ = lambda x, y: 'test_id'
url = reverse('api:v1:annotations') + '?refresh=false' url = reverse('api:v1:annotations') + '?refresh=false'
response = self.client.post(url, {}, format='json', **self.headers) response = self.client.post(url, {}, format='json', **self.headers)
ann_mock.return_value.save.assert_called_once_with(refresh=False) mocked_annotation.return_value.save.assert_called_once_with(refresh=False)
def test_read(self): def test_read(self):
""" """
......
...@@ -54,7 +54,7 @@ class AnnotationListView(APIView): ...@@ -54,7 +54,7 @@ class AnnotationListView(APIView):
""" """
Get a list of all annotations. Get a list of all annotations.
""" """
# TODO: get user. # TODO: get user when auth will be done.
user = None user = None
annotations = Annotation.search(user) annotations = Annotation.search(user)
...@@ -65,12 +65,12 @@ class AnnotationListView(APIView): ...@@ -65,12 +65,12 @@ class AnnotationListView(APIView):
""" """
Create a new annotation. Create a new annotation.
""" """
if request.DATA is not None: annotation = Annotation(_filter_input(request.DATA, CREATE_FILTER_FIELDS))
annotation = Annotation(_filter_input(request.DATA, CREATE_FILTER_FIELDS))
refresh = request.QUERY_PARAMS.get('refresh') != u'false' refresh = request.QUERY_PARAMS.get('refresh') != u'false'
annotation.save(refresh=refresh) annotation.save(refresh=refresh)
location = reverse('api:v1:annotations_detail', kwargs={'annotation_id': annotation['id']}) location = reverse('api:v1:annotations_detail', kwargs={'annotation_id': annotation['id']})
return Response(annotation, status=status.HTTP_201_CREATED, headers={'Location': location}) return Response(annotation, status=status.HTTP_201_CREATED, headers={'Location': location})
......
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