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)
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)
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)
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)
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)
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']))
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)
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)
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)
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)
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)
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)
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)
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)
def test_it_returns_object(self): annotation = mock.Mock() request = mock.Mock() result = views.delete(annotation, request) assert result == {'id': annotation.id, 'deleted': True}
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']
def test_delete_returns_object(): context = mock.Mock() request = mock.Mock() result = views.delete(context, request) assert result == {'id': context.id, 'deleted': True}
def test_delete_returns_object(): annotation = mock.Mock() request = mock.Mock() result = views.delete(annotation, request) assert result == {'id': annotation.id, 'deleted': True}
def test_delete_calls_delete(): annotation = _mock_annotation(id='foo') views.delete(annotation, mock.Mock()) annotation.delete.assert_called_once_with()
def test_delete_returns_id(): annotation = _mock_annotation(id='foo') response_data = views.delete(annotation, mock.Mock()) assert response_data['id'] == annotation['id']
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
def test_delete_returns_deleted(): response_data = views.delete(_mock_annotation(id='foo'), mock.Mock()) assert response_data['deleted'] is True
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']))