Beispiel #1
0
    def test_it_deletes_then_annotation_from_storage(self, pyramid_request, storage):
        annotation = mock.Mock()

        views.delete(annotation, pyramid_request)

        storage.delete_annotation.assert_called_once_with(pyramid_request.db,
                                                          annotation.id)
Beispiel #2
0
    def test_it_deletes_then_annotation_from_storage(self, pyramid_request, storage):
        annotation = mock.Mock()

        views.delete(annotation, pyramid_request)

        storage.delete_annotation.assert_called_once_with(pyramid_request.db,
                                                          annotation.id)
Beispiel #3
0
    def test_it_serializes_the_annotation(self, AnnotationJSONPresenter,
                                          links_service, pyramid_request):
        annotation = mock.Mock()

        views.delete(annotation, pyramid_request)

        AnnotationJSONPresenter.assert_called_once_with(
            annotation, links_service)
Beispiel #4
0
    def test_it_serializes_the_annotation(self,
                                          AnnotationJSONPresenter,
                                          links_service,
                                          pyramid_request):
        annotation = mock.Mock()

        views.delete(annotation, pyramid_request)

        AnnotationJSONPresenter.assert_called_once_with(annotation, links_service)
Beispiel #5
0
    def test_it_inits_and_fires_an_AnnotationEvent(self, AnnotationEvent,
                                                   AnnotationJSONPresenter,
                                                   pyramid_request):
        context = mock.Mock()
        event = AnnotationEvent.return_value

        views.delete(context, pyramid_request)

        AnnotationEvent.assert_called_once_with(pyramid_request,
                                                context.annotation.id,
                                                'delete')
        pyramid_request.notify_after_commit.assert_called_once_with(event)
Beispiel #6
0
    def test_it_inits_and_fires_an_AnnotationEvent(self,
                                                   AnnotationEvent,
                                                   AnnotationJSONPresenter,
                                                   pyramid_request):
        context = mock.Mock()
        event = AnnotationEvent.return_value

        views.delete(context, pyramid_request)

        AnnotationEvent.assert_called_once_with(pyramid_request,
                                                context.annotation.id,
                                                'delete')
        pyramid_request.notify_after_commit.assert_called_once_with(event)
Beispiel #7
0
    def test_it_inits_and_fires_an_AnnotationEvent(self,
                                                   AnnotationEvent,
                                                   AnnotationJSONPresenter,
                                                   pyramid_request):
        annotation = mock.Mock()
        event = AnnotationEvent.return_value
        annotation_dict = AnnotationJSONPresenter.return_value.asdict.return_value

        views.delete(annotation, pyramid_request)

        AnnotationEvent.assert_called_once_with(pyramid_request,
                                                annotation.id,
                                                'delete',
                                                annotation_dict=annotation_dict)
        pyramid_request.notify_after_commit.assert_called_once_with(event)
Beispiel #8
0
    def test_it_inits_and_fires_an_AnnotationEvent(self,
                                                   AnnotationEvent,
                                                   AnnotationJSONPresenter,
                                                   pyramid_request):
        annotation = mock.Mock()
        event = AnnotationEvent.return_value
        annotation_dict = AnnotationJSONPresenter.return_value.asdict.return_value

        views.delete(annotation, pyramid_request)

        AnnotationEvent.assert_called_once_with(pyramid_request,
                                                annotation.id,
                                                'delete',
                                                annotation_dict=annotation_dict)
        pyramid_request.notify_after_commit.assert_called_once_with(event)
Beispiel #9
0
    def test_it_returns_object(self, pyramid_request):
        annotation = mock.Mock()

        result = views.delete(annotation, pyramid_request)

        assert result == {'id': annotation.id, 'deleted': True}
Beispiel #10
0
    def test_it_returns_object(self, pyramid_request):
        annotation = mock.Mock()

        result = views.delete(annotation, pyramid_request)

        assert result == {'id': annotation.id, 'deleted': True}