Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    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()
Example #8
0
    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
Example #9
0
    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
Example #10
0
    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()
Example #11
0
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}
Example #12
0
File: views.py Project: hashin/h
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}
Example #13
0
File: users.py Project: ficolo/h
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)
Example #14
0
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)
Example #15
0
    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()
Example #16
0
File: views.py Project: VanyTang/h
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}
Example #17
0
    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()