Exemple #1
0
def test_delete_calls_delete_annotation(storage):
    context = mock.Mock()
    request = mock.Mock()

    views.delete(context, request)

    storage.delete_annotation.assert_called_once_with(context.id)
Exemple #2
0
def test_delete_event(AnnotationEvent):
    request = mock.Mock()
    annotation = _mock_annotation(id='foo')
    event = AnnotationEvent.return_value
    views.delete(annotation, request)
    AnnotationEvent.assert_called_once_with(request, annotation, 'delete')
    request.registry.notify.assert_called_once_with(event)
Exemple #3
0
    def test_it_serializes_the_annotation(self, AnnotationJSONPresenter):
        annotation = mock.Mock()
        request = mock.Mock()

        views.delete(annotation, request)

        AnnotationJSONPresenter.assert_called_once_with(request, annotation)
Exemple #4
0
def test_delete_calls_delete_annotation(logic):
    annotation = mock.MagicMock()
    request = mock.Mock()

    views.delete(annotation, request)

    logic.delete_annotation.assert_called_once_with(annotation.model)
Exemple #5
0
def test_delete_calls_delete_annotation(storage):
    annotation = mock.Mock()
    request = mock.Mock()

    views.delete(annotation, request)

    storage.delete_annotation.assert_called_once_with(request, annotation.id)
Exemple #6
0
def test_delete_does_not_crash_if_annotation_has_no_group():
    annotation = _mock_annotation(id='foo')
    assert 'group' not in annotation

    views.delete(
        annotation,
        mock.Mock(effective_principals=['group:test-group']))
Exemple #7
0
def test_delete_calls_delete_annotation(logic):
    annotation = mock.MagicMock()
    request = mock.Mock()

    views.delete(annotation, request)

    logic.delete_annotation.assert_called_once_with(annotation.model)
Exemple #8
0
def test_delete_event(AnnotationEvent):
    request = mock.Mock()
    annotation = _mock_annotation(id='foo')
    event = AnnotationEvent.return_value
    views.delete(annotation, request)
    AnnotationEvent.assert_called_once_with(request, annotation, 'delete')
    request.registry.notify.assert_called_once_with(event)
Exemple #9
0
    def test_it_serializes_the_annotation(self, AnnotationJSONPresenter):
        annotation = mock.Mock()
        request = mock.Mock()

        views.delete(annotation, request)

        AnnotationJSONPresenter.assert_called_once_with(request, annotation)
Exemple #10
0
def test_delete_calls_delete_annotation(storage):
    annotation = mock.Mock()
    request = mock.Mock()

    views.delete(annotation, request)

    storage.delete_annotation.assert_called_once_with(request, annotation.id)
Exemple #11
0
    def test_it_deletes_then_annotation_from_storage(self, storage):
        annotation = mock.Mock()
        request = mock.Mock()

        views.delete(annotation, request)

        storage.delete_annotation.assert_called_once_with(request.db,
                                                          annotation.id)
Exemple #12
0
    def test_it_deletes_then_annotation_from_storage(self, storage):
        annotation = mock.Mock()
        request = mock.Mock()

        views.delete(annotation, request)

        storage.delete_annotation.assert_called_once_with(
            request.db, annotation.id)
Exemple #13
0
    def test_it_calls_notify_with_an_event(self, AnnotationEvent):
        annotation = mock.Mock()
        request = mock.Mock()
        event = AnnotationEvent.return_value

        views.delete(annotation, request)

        AnnotationEvent.assert_called_once_with(request, annotation, 'delete')
        request.registry.notify.assert_called_once_with(event)
Exemple #14
0
def test_delete_event(AnnotationEvent):
    annotation = _mock_annotation(id='foo', group='test-group')
    request = mock.Mock(effective_principals=['group:test-group'])
    event = AnnotationEvent.return_value

    views.delete(annotation, request)

    AnnotationEvent.assert_called_once_with(request, annotation.model, 'delete')
    request.registry.notify.assert_called_once_with(event)
Exemple #15
0
    def test_it_calls_notify_with_an_event(self, AnnotationEvent):
        annotation = mock.Mock()
        request = mock.Mock()
        event = AnnotationEvent.return_value

        views.delete(annotation, request)

        AnnotationEvent.assert_called_once_with(request, annotation, 'delete')
        request.registry.notify.assert_called_once_with(event)
Exemple #16
0
def test_delete_event(AnnotationEvent):
    context = mock.Mock()
    request = mock.Mock()
    event = AnnotationEvent.return_value

    views.delete(context, request)

    AnnotationEvent.assert_called_once_with(request, context.model, 'delete')
    request.registry.notify.assert_called_once_with(event)
Exemple #17
0
def test_delete_event(AnnotationEvent):
    annotation = _mock_annotation(id='foo', group='test-group')
    request = mock.Mock(effective_principals=['group:test-group'])
    event = AnnotationEvent.return_value

    views.delete(annotation, request)

    AnnotationEvent.assert_called_once_with(request, annotation.model,
                                            'delete')
    request.registry.notify.assert_called_once_with(event)
Exemple #18
0
    def test_it_calls_notify_with_an_event(self, AnnotationEvent, AnnotationJSONPresenter):
        annotation = mock.Mock()
        request = mock.Mock()
        event = AnnotationEvent.return_value

        views.delete(annotation, request)

        AnnotationJSONPresenter.assert_called_once_with(request, annotation)
        presented = AnnotationJSONPresenter.return_value.asdict()

        AnnotationEvent.assert_called_once_with(request, presented, 'delete')
        request.notify_after_commit.assert_called_once_with(event)
Exemple #19
0
    def test_it_inits_and_fires_an_AnnotationEvent(self, AnnotationEvent,
                                                   AnnotationJSONPresenter):
        annotation = mock.Mock()
        request = mock.Mock()
        event = AnnotationEvent.return_value
        annotation_dict = AnnotationJSONPresenter.return_value.asdict.return_value

        views.delete(annotation, request)

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

        views.delete(annotation, request)

        AnnotationEvent.assert_called_once_with(request, annotation.id, 'delete',
                                                annotation_dict=annotation_dict)
        request.notify_after_commit.assert_called_once_with(event)
Exemple #21
0
    def test_it_returns_object(self):
        annotation = mock.Mock()
        request = mock.Mock()

        result = views.delete(annotation, request)

        assert result == {'id': annotation.id, 'deleted': True}
Exemple #22
0
def test_delete_returns_id():
    annotation = _mock_annotation(id='foo', group='test-group')

    response_data = views.delete(
        annotation, mock.Mock(effective_principals=['group:test-group']))

    assert response_data['id'] == annotation.model['id']
Exemple #23
0
def test_delete_returns_id():
    annotation = _mock_annotation(id='foo', group='test-group')

    response_data = views.delete(
        annotation, mock.Mock(effective_principals=['group:test-group']))

    assert response_data['id'] == annotation.model['id']
Exemple #24
0
def test_delete_returns_object():
    context = mock.Mock()
    request = mock.Mock()

    result = views.delete(context, request)

    assert result == {'id': context.id, 'deleted': True}
Exemple #25
0
def test_delete_returns_object():
    annotation = mock.Mock()
    request = mock.Mock()

    result = views.delete(annotation, request)

    assert result == {'id': annotation.id, 'deleted': True}
Exemple #26
0
def test_delete_calls_delete():
    annotation = _mock_annotation(id='foo')

    views.delete(annotation, mock.Mock())

    annotation.delete.assert_called_once_with()
Exemple #27
0
def test_delete_returns_id():
    annotation = _mock_annotation(id='foo')

    response_data = views.delete(annotation, mock.Mock())

    assert response_data['id'] == annotation['id']
Exemple #28
0
def test_delete_returns_deleted():
    response_data = views.delete(
        _mock_annotation(id='foo', group='test-group'),
        mock.Mock(effective_principals=['group:test-group']))

    assert response_data['deleted'] is True
Exemple #29
0
def test_delete_returns_deleted():
    response_data = views.delete(_mock_annotation(id='foo'), mock.Mock())

    assert response_data['deleted'] is True
Exemple #30
0
def test_delete_does_not_crash_if_annotation_has_no_group():
    annotation = _mock_annotation(id='foo')
    assert 'group' not in annotation

    views.delete(annotation,
                 mock.Mock(effective_principals=['group:test-group']))
Exemple #31
0
def test_delete_returns_deleted():
    response_data = views.delete(_mock_annotation(id='foo'), mock.Mock())

    assert response_data['deleted'] is True
Exemple #32
0
def test_delete_returns_id():
    annotation = _mock_annotation(id='foo')

    response_data = views.delete(annotation, mock.Mock())

    assert response_data['id'] == annotation['id']
Exemple #33
0
def test_delete_calls_delete():
    annotation = _mock_annotation(id='foo')

    views.delete(annotation, mock.Mock())

    annotation.delete.assert_called_once_with()
Exemple #34
0
def test_delete_returns_deleted():
    response_data = views.delete(
        _mock_annotation(id='foo', group='test-group'),
        mock.Mock(effective_principals=['group:test-group']))

    assert response_data['deleted'] is True