def test_it_only_fetches_the_legacy_annotation(self, fetch_annotation): request = self.mock_request() storage.delete_annotation(request, "test_id") fetch_annotation.assert_called_once_with( request, "test_id", _postgres=False)
def test_it_fetches_the_annotation(self, fetch_annotation): request = self.mock_request() storage.delete_annotation(request, "test_id") assert fetch_annotation.call_args_list[0] == mock.call(request, "test_id", _postgres=True)
def test_it_fetches_the_legacy_annotation(self, fetch_annotation): request = self.mock_request() storage.delete_annotation(request, "test_id") assert fetch_annotation.call_args == mock.call(request, "test_id", _postgres=False)
def test_it_deletes_the_legacy_annotation(self, fetch_annotation): first_return_value = mock.Mock() second_return_value = mock.Mock() fetch_annotation.side_effect = [ first_return_value, second_return_value, ] storage.delete_annotation(self.mock_request(), "test_id") second_return_value.delete.assert_called_once_with()
def test_it_deletes_the_annotation(self, db_session): ann_1 = Annotation(userid='luke') ann_2 = Annotation(userid='leia') db_session.add_all([ann_1, ann_2]) db_session.flush() storage.delete_annotation(db_session, ann_1.id) db_session.commit() assert db_session.query(Annotation).get(ann_1.id) is None assert db_session.query(Annotation).get(ann_2.id) == ann_2
def delete(annotation, request): """Delete the specified annotation.""" storage.delete_annotation(request, annotation.id) # N.B. We publish the original model (including all the original annotation # fields) so that queue subscribers have context needed to decide how to # process the delete event. For example, the streamer needs to know the # target URLs of the deleted annotation in order to know which clients to # forward the delete event to. _publish_annotation_event(request, annotation, 'delete') return {'id': annotation.id, 'deleted': True}
def delete_user(request, user): """ Deletes a user with all their group memberships and annotations. Raises UserDeletionError when deletion fails with the appropriate error message. """ if models.Group.created_by(user).count() > 0: raise UserDeletionError('Cannot delete user who is a group creator.') user.groups = [] query = _all_user_annotations_query(request, user) annotations = es_helpers.scan(client=request.es.conn, query={'query': query}) for annotation in annotations: storage.delete_annotation(request.db, annotation['_id']) request.db.delete(user)
def test_it_deletes_the_legacy_annotation(self, fetch_annotation): storage.delete_annotation(self.mock_request(), "test_id") fetch_annotation.return_value.delete.assert_called_once_with()
def delete(context, request): """Delete the specified annotation.""" storage.delete_annotation(context.id) _publish_annotation_event(request, {'id': context.id}, 'delete') return {'id': context.id, 'deleted': True}