Esempio n. 1
0
    def test_it_validates_the_group_scope(self, pyramid_request, annotation,
                                          _validate_group_scope):
        storage.update_annotation(pyramid_request, annotation.id,
                                  {"target_uri": "sentinel.target_uri"})

        _validate_group_scope.assert_called_once_with(annotation.group,
                                                      "sentinel.target_uri")
Esempio n. 2
0
    def test_it_raises_if_missing_group(self, annotation_data, pyramid_request, group_service):
        group_service.find.return_value = None

        with pytest.raises(ValidationError) as exc:
            storage.update_annotation(pyramid_request, 'test_annotation_id', annotation_data, group_service)

        assert str(exc.value).startswith('group: ')
Esempio n. 3
0
    def test_it_updates_the_document_metadata_from_the_annotation(
            self,
            annotation_data,
            pyramid_request,
            datetime,
            update_document_metadata,
            group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation_data['document']['document_meta_dicts'] = (
            mock.sentinel.document_meta_dicts)
        annotation_data['document']['document_uri_dicts'] = (
            mock.sentinel.document_uri_dicts)

        storage.update_annotation(pyramid_request,
                                  'test_annotation_id',
                                  annotation_data,
                                  group_service)

        update_document_metadata.assert_called_once_with(
            pyramid_request.db,
            annotation.target_uri,
            mock.sentinel.document_meta_dicts,
            mock.sentinel.document_uri_dicts,
            updated=datetime.utcnow()
        )
Esempio n. 4
0
    def test_it_does_not_call_update_document_meta_if_no_document_in_data(
            self, pyramid_request, update_document_metadata, group_service):

        storage.update_annotation(pyramid_request, "test_annotation_id", {},
                                  group_service)

        assert not update_document_metadata.called
Esempio n. 5
0
    def test_it_updates_the_document_metadata_from_the_annotation(
        self,
        annotation_data,
        pyramid_request,
        datetime,
        update_document_metadata,
        groupfinder_service,
    ):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation_data["document"][
            "document_meta_dicts"
        ] = mock.sentinel.document_meta_dicts
        annotation_data["document"][
            "document_uri_dicts"
        ] = mock.sentinel.document_uri_dicts

        storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, groupfinder_service
        )

        update_document_metadata.assert_called_once_with(
            pyramid_request.db,
            annotation.target_uri,
            mock.sentinel.document_meta_dicts,
            mock.sentinel.document_uri_dicts,
            updated=datetime.utcnow(),
        )
Esempio n. 6
0
    def test_it_updates_the_document_metadata_from_the_annotation(
            self,
            annotation_data,
            pyramid_request,
            datetime,
            update_document_metadata,
            group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation_data['document']['document_meta_dicts'] = (
            mock.sentinel.document_meta_dicts)
        annotation_data['document']['document_uri_dicts'] = (
            mock.sentinel.document_uri_dicts)

        storage.update_annotation(pyramid_request,
                                  'test_annotation_id',
                                  annotation_data,
                                  group_service)

        update_document_metadata.assert_called_once_with(
            pyramid_request.db,
            annotation.target_uri,
            mock.sentinel.document_meta_dicts,
            mock.sentinel.document_uri_dicts,
            updated=datetime.utcnow()
        )
Esempio n. 7
0
    def test_it_raises_if_missing_group(self, annotation_data, pyramid_request, group_service):
        group_service.find.return_value = None

        with pytest.raises(ValidationError) as exc:
            storage.update_annotation(pyramid_request, 'test_annotation_id', annotation_data, group_service)

        assert str(exc.value).startswith('group: ')
Esempio n. 8
0
    def test_it_raises_when_group_scope_mismatch(self, annotation_data, pyramid_request, group_service, scoped_open_group):
        annotation_data['target_uri'] = u'http://www.bar.com/baz/ding.html'
        group_service.find.return_value = scoped_open_group

        with pytest.raises(ValidationError) as exc:
            storage.update_annotation(pyramid_request, 'test_annotation_id', annotation_data, group_service)

        assert str(exc.value).startswith('group scope: ')
Esempio n. 9
0
    def test_it_updates_the_annotation(self, annotation_data, session):
        annotation = session.query.return_value.get.return_value

        storage.update_annotation(session, 'test_annotation_id',
                                  annotation_data)

        for key, value in annotation_data.items():
            assert getattr(annotation, key) == value
Esempio n. 10
0
    def test_it_raises_when_group_scope_mismatch(self, annotation_data, pyramid_request, group_service, scoped_open_group):
        annotation_data['target_uri'] = 'http://www.bar.com/baz/ding.html'
        group_service.find.return_value = scoped_open_group

        with pytest.raises(ValidationError) as exc:
            storage.update_annotation(pyramid_request, 'test_annotation_id', annotation_data, group_service)

        assert str(exc.value).startswith('group scope: ')
Esempio n. 11
0
    def test_it_queues_the_annotation_for_syncing_to_Elasticsearch(
            self, annotation, pyramid_request, search_index):
        storage.update_annotation(pyramid_request, annotation.id, {})

        search_index._queue.add_by_id.assert_called_once_with(  # pylint:disable=protected-access
            annotation.id,
            tag="storage.update_annotation",
            schedule_in=60)
Esempio n. 12
0
    def test_it_gets_the_annotation_model(self, annotation_data, models,
                                          session):
        storage.update_annotation(session, 'test_annotation_id',
                                  annotation_data)

        session.query.assert_called_once_with(models.Annotation)
        session.query.return_value.get.assert_called_once_with(
            'test_annotation_id')
Esempio n. 13
0
    def test_it_does_not_call_update_document_meta_if_no_document_in_data(
            self,
            session,
            update_document_metadata):

        storage.update_annotation(session, 'test_annotation_id', {})

        assert not update_document_metadata.called
Esempio n. 14
0
    def test_it_gets_the_annotation_model(self, pyramid_request,
                                          annotation_data, group_service,
                                          models):
        storage.update_annotation(pyramid_request, "test_annotation_id",
                                  annotation_data, group_service)

        pyramid_request.db.query.assert_called_once_with(models.Annotation)
        pyramid_request.db.query.return_value.get.assert_called_once_with(
            "test_annotation_id")
Esempio n. 15
0
    def test_it_updates_the_annotations_document_id(self, annotation_data,
                                                    session, models):
        annotation = session.query.return_value.get.return_value
        document = mock.Mock()
        models.update_document_metadata.return_value = document

        storage.update_annotation(session, 'test_annotation_id',
                                  annotation_data)
        assert annotation.document == document
Esempio n. 16
0
    def test_it_overwrites_existing_extras(self, annotation_data, session):
        annotation = session.query.return_value.get.return_value
        annotation.extra = {'foo': 'original_value'}
        annotation_data['extra'] = {'foo': 'new_value'}

        storage.update_annotation(session, 'test_annotation_id',
                                  annotation_data)

        assert annotation.extra == {'foo': 'new_value'}
Esempio n. 17
0
    def test_it_updates_the_annotation(self, annotation_data, session):
        annotation = session.query.return_value.get.return_value

        storage.update_annotation(session,
                                  'test_annotation_id',
                                  annotation_data)

        for key, value in annotation_data.items():
            assert getattr(annotation, key) == value
Esempio n. 18
0
    def test_it_does_not_call_update_document_meta_if_no_document_in_data(
            self,
            pyramid_request,
            update_document_metadata,
            group_service):

        storage.update_annotation(pyramid_request, 'test_annotation_id', {}, group_service)

        assert not update_document_metadata.called
Esempio n. 19
0
    def test_it_adds_new_extras(self, annotation_data, session):
        annotation = session.query.return_value.get.return_value
        annotation.extra = {}
        annotation_data['extra'] = {'foo': 'bar'}

        storage.update_annotation(session, 'test_annotation_id',
                                  annotation_data)

        assert annotation.extra == {'foo': 'bar'}
Esempio n. 20
0
    def test_it_updates_the_annotation(self, annotation_data, pyramid_request,
                                       group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value

        storage.update_annotation(pyramid_request, "test_annotation_id",
                                  annotation_data, group_service)

        for key, value in annotation_data.items():
            assert getattr(annotation, key) == value
Esempio n. 21
0
    def test_it_adds_new_extras(self, pyramid_request, annotation_data,
                                group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {}
        annotation_data["extra"] = {"foo": "bar"}

        storage.update_annotation(pyramid_request, "test_annotation_id",
                                  annotation_data, group_service)

        assert annotation.extra == {"foo": "bar"}
Esempio n. 22
0
    def test_it_does_not_change_extras_if_none_are_sent(
            self, pyramid_request, annotation_data, group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {'one': 1, 'two': 2}
        assert not annotation_data.get('extra')

        storage.update_annotation(pyramid_request, 'test_annotation_id',
                                  annotation_data, group_service)

        assert annotation.extra == {'one': 1, 'two': 2}
Esempio n. 23
0
    def test_it_does_not_change_extras_if_none_are_sent(
            self, pyramid_request, annotation_data, group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {"one": 1, "two": 2}
        assert not annotation_data.get("extra")

        storage.update_annotation(pyramid_request, "test_annotation_id",
                                  annotation_data, group_service)

        assert annotation.extra == {"one": 1, "two": 2}
Esempio n. 24
0
    def test_it_overwrites_existing_extras(self, pyramid_request,
                                           annotation_data, group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {'foo': 'original_value'}
        annotation_data['extra'] = {'foo': 'new_value'}

        storage.update_annotation(pyramid_request, 'test_annotation_id',
                                  annotation_data, group_service)

        assert annotation.extra == {'foo': 'new_value'}
Esempio n. 25
0
    def test_it_adds_new_extras(self, annotation_data, session):
        annotation = session.query.return_value.get.return_value
        annotation.extra = {}
        annotation_data['extra'] = {'foo': 'bar'}

        storage.update_annotation(session,
                                  'test_annotation_id',
                                  annotation_data)

        assert annotation.extra == {'foo': 'bar'}
Esempio n. 26
0
    def test_it_updates_the_annotation(self, annotation_data, pyramid_request, group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value

        storage.update_annotation(pyramid_request,
                                  'test_annotation_id',
                                  annotation_data,
                                  group_service)

        for key, value in annotation_data.items():
            assert getattr(annotation, key) == value
Esempio n. 27
0
    def test_it_does_not_change_extras_if_none_are_sent(
            self, annotation_data, session):
        annotation = session.query.return_value.get.return_value
        annotation.extra = {'one': 1, 'two': 2}
        assert not annotation_data.get('extra')

        storage.update_annotation(session, 'test_annotation_id',
                                  annotation_data)

        assert annotation.extra == {'one': 1, 'two': 2}
Esempio n. 28
0
    def test_it_overwrites_existing_extras(self, pyramid_request,
                                           annotation_data, group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {"foo": "original_value"}
        annotation_data["extra"] = {"foo": "new_value"}

        storage.update_annotation(pyramid_request, "test_annotation_id",
                                  annotation_data, group_service)

        assert annotation.extra == {"foo": "new_value"}
Esempio n. 29
0
    def test_it_queues_the_annotation_for_syncing_to_Elasticsearch(
        self, annotation_data, groupfinder_service, pyramid_request, search_index
    ):
        storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, groupfinder_service
        )

        search_index._queue.add_by_id.assert_called_once_with(
            "test_annotation_id", tag="storage.update_annotation", schedule_in=60
        )
Esempio n. 30
0
    def test_it_adds_new_extras(self, pyramid_request, annotation_data,
                                group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {}
        annotation_data['extra'] = {'foo': 'bar'}

        storage.update_annotation(pyramid_request, 'test_annotation_id',
                                  annotation_data, group_service)

        assert annotation.extra == {'foo': 'bar'}
Esempio n. 31
0
    def test_it_adds_new_extras(self, pyramid_request, annotation_data, group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {}
        annotation_data["extra"] = {"foo": "bar"}

        storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, group_service
        )

        assert annotation.extra == {"foo": "bar"}
Esempio n. 32
0
    def test_it_gets_the_annotation_model(self,
                                          annotation_data,
                                          models,
                                          session):
        storage.update_annotation(session,
                                  'test_annotation_id',
                                  annotation_data)

        session.query.assert_called_once_with(models.Annotation)
        session.query.return_value.get.assert_called_once_with(
            'test_annotation_id')
Esempio n. 33
0
    def test_it_updates_the_annotations_document_id(
        self, annotation_data, pyramid_request, update_document_metadata, group_service
    ):
        annotation = pyramid_request.db.query.return_value.get.return_value
        document = mock.Mock()
        update_document_metadata.return_value = document

        storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, group_service
        )
        assert annotation.document == document
Esempio n. 34
0
    def test_it_adds_new_extras(self, pyramid_request, annotation_data, group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {}
        annotation_data['extra'] = {'foo': 'bar'}

        storage.update_annotation(pyramid_request,
                                  'test_annotation_id',
                                  annotation_data,
                                  group_service)

        assert annotation.extra == {'foo': 'bar'}
Esempio n. 35
0
    def test_it_updates_the_annotations_document_id(self, annotation_data,
                                                    pyramid_request,
                                                    update_document_metadata,
                                                    group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        document = mock.Mock()
        update_document_metadata.return_value = document

        storage.update_annotation(pyramid_request, "test_annotation_id",
                                  annotation_data, group_service)
        assert annotation.document == document
Esempio n. 36
0
    def test_it_gets_the_annotation_model(
        self, pyramid_request, annotation_data, group_service, models
    ):
        storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, group_service
        )

        pyramid_request.db.query.assert_called_once_with(models.Annotation)
        pyramid_request.db.query.return_value.get.assert_called_once_with(
            "test_annotation_id"
        )
Esempio n. 37
0
    def test_it_does_not_change_extras_if_none_are_sent(self,
                                                        annotation_data,
                                                        session):
        annotation = session.query.return_value.get.return_value
        annotation.extra = {'one': 1, 'two': 2}
        assert not annotation_data.get('extra')

        storage.update_annotation(session,
                                  'test_annotation_id',
                                  annotation_data)

        assert annotation.extra == {'one': 1, 'two': 2}
Esempio n. 38
0
    def test_it_updates_the_annotations_document_id(self,
                                                    annotation_data,
                                                    session,
                                                    update_document_metadata):
        annotation = session.query.return_value.get.return_value
        document = mock.Mock()
        update_document_metadata.return_value = document

        storage.update_annotation(session,
                                  'test_annotation_id',
                                  annotation_data)
        assert annotation.document == document
Esempio n. 39
0
    def test_it_does_not_change_extras_if_none_are_sent(
        self, pyramid_request, annotation_data, group_service
    ):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {"one": 1, "two": 2}
        assert not annotation_data.get("extra")

        storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, group_service
        )

        assert annotation.extra == {"one": 1, "two": 2}
Esempio n. 40
0
    def test_it_does_not_change_extras_that_are_not_sent(
        self, pyramid_request, annotation_data, groupfinder_service
    ):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {"one": 1, "two": 2}
        annotation_data["extra"] = {"two": 22}

        storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, groupfinder_service
        )

        assert annotation.extra["one"] == 1
Esempio n. 41
0
    def test_it_overwrites_existing_extras(
        self, pyramid_request, annotation_data, group_service
    ):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {"foo": "original_value"}
        annotation_data["extra"] = {"foo": "new_value"}

        storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, group_service
        )

        assert annotation.extra == {"foo": "new_value"}
Esempio n. 42
0
    def test_it_overwrites_existing_extras(self,
                                           annotation_data,
                                           session):
        annotation = session.query.return_value.get.return_value
        annotation.extra = {'foo': 'original_value'}
        annotation_data['extra'] = {'foo': 'new_value'}

        storage.update_annotation(session,
                                  'test_annotation_id',
                                  annotation_data)

        assert annotation.extra == {'foo': 'new_value'}
Esempio n. 43
0
    def test_it_does_not_change_extras_that_are_not_sent(
            self, pyramid_request, annotation_data, group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {
            'one': 1,
            'two': 2,
        }
        annotation_data['extra'] = {'two': 22}

        storage.update_annotation(pyramid_request, 'test_annotation_id',
                                  annotation_data, group_service)

        assert annotation.extra['one'] == 1
Esempio n. 44
0
    def test_it_raises_when_group_scope_mismatch(
        self, annotation_data, pyramid_request, group_service, scoped_open_group
    ):
        # This target URI does not match any of the group's defined scopes
        annotation_data["target_uri"] = "http://www.bar.com/baz/ding.html"
        group_service.find.return_value = scoped_open_group

        with pytest.raises(ValidationError) as exc:
            storage.update_annotation(
                pyramid_request, "test_annotation_id", annotation_data, group_service
            )

        assert str(exc.value).startswith("group scope: ")
Esempio n. 45
0
    def test_it_raises_when_group_scope_mismatch(self, annotation_data,
                                                 pyramid_request,
                                                 group_service,
                                                 scoped_open_group):
        # This target URI does not match any of the group's defined scopes
        annotation_data["target_uri"] = "http://www.bar.com/baz/ding.html"
        group_service.find.return_value = scoped_open_group

        with pytest.raises(ValidationError) as exc:
            storage.update_annotation(pyramid_request, "test_annotation_id",
                                      annotation_data, group_service)

        assert str(exc.value).startswith("group scope: ")
Esempio n. 46
0
    def test_it_does_not_change_extras_that_are_not_sent(
            self, annotation_data, session):
        annotation = session.query.return_value.get.return_value
        annotation.extra = {
            'one': 1,
            'two': 2,
        }
        annotation_data['extra'] = {'two': 22}

        storage.update_annotation(session, 'test_annotation_id',
                                  annotation_data)

        assert annotation.extra['one'] == 1
Esempio n. 47
0
    def test_it_does_not_change_extras_if_none_are_sent(self,
                                                        pyramid_request,
                                                        annotation_data,
                                                        group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {'one': 1, 'two': 2}
        assert not annotation_data.get('extra')

        storage.update_annotation(pyramid_request,
                                  'test_annotation_id',
                                  annotation_data,
                                  group_service)

        assert annotation.extra == {'one': 1, 'two': 2}
Esempio n. 48
0
    def test_it_overwrites_existing_extras(self,
                                           pyramid_request,
                                           annotation_data,
                                           group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {'foo': 'original_value'}
        annotation_data['extra'] = {'foo': 'new_value'}

        storage.update_annotation(pyramid_request,
                                  'test_annotation_id',
                                  annotation_data,
                                  group_service)

        assert annotation.extra == {'foo': 'new_value'}
Esempio n. 49
0
    def test_it_does_not_change_extras_that_are_not_sent(self,
                                                         annotation_data,
                                                         session):
        annotation = session.query.return_value.get.return_value
        annotation.extra = {
            'one': 1,
            'two': 2,
        }
        annotation_data['extra'] = {'two': 22}

        storage.update_annotation(session,
                                  'test_annotation_id',
                                  annotation_data)

        assert annotation.extra['one'] == 1
Esempio n. 50
0
    def test_it_returns_the_annotation(self, annotation_data, pyramid_request, group_service):
        annotation = storage.update_annotation(pyramid_request,
                                               'test_annotation_id',
                                               annotation_data,
                                               group_service)

        assert annotation == pyramid_request.db.query.return_value.get.return_value
Esempio n. 51
0
    def test_it_changes_the_updated_timestamp(self, annotation_data, pyramid_request, datetime, group_service):
        annotation = storage.update_annotation(pyramid_request,
                                               'test_annotation_id',
                                               annotation_data,
                                               group_service)

        assert annotation.updated == datetime.utcnow()
Esempio n. 52
0
    def test_it_allows_when_group_scope_matches(self, annotation_data, pyramid_request, group_service, scoped_open_group, models):
        annotation_data['target_uri'] = 'http://www.foo.com/baz/ding.html'

        # this should not raise
        annotation = storage.update_annotation(pyramid_request, 'test_annotation_id', annotation_data, group_service)

        assert annotation == pyramid_request.db.query.return_value.get.return_value
Esempio n. 53
0
    def test_it_returns_the_annotation(self, annotation_data, pyramid_request,
                                       group_service):
        annotation = storage.update_annotation(pyramid_request,
                                               "test_annotation_id",
                                               annotation_data, group_service)

        assert annotation == pyramid_request.db.query.return_value.get.return_value
Esempio n. 54
0
    def test_it_changes_the_updated_timestamp(self, annotation_data, pyramid_request, datetime, group_service):
        annotation = storage.update_annotation(pyramid_request,
                                               'test_annotation_id',
                                               annotation_data,
                                               group_service)

        assert annotation.updated == datetime.utcnow()
Esempio n. 55
0
    def test_it_allows_when_group_scope_matches(self, annotation_data, pyramid_request, group_service, scoped_open_group, models):
        annotation_data['target_uri'] = u'http://www.foo.com/baz/ding.html'

        # this should not raise
        annotation = storage.update_annotation(pyramid_request, 'test_annotation_id', annotation_data, group_service)

        assert annotation == pyramid_request.db.query.return_value.get.return_value
Esempio n. 56
0
    def test_it_does_not_change_extras_that_are_not_sent(self,
                                                         pyramid_request,
                                                         annotation_data,
                                                         group_service):
        annotation = pyramid_request.db.query.return_value.get.return_value
        annotation.extra = {
            'one': 1,
            'two': 2,
        }
        annotation_data['extra'] = {'two': 22}

        storage.update_annotation(pyramid_request,
                                  'test_annotation_id',
                                  annotation_data,
                                  group_service)

        assert annotation.extra['one'] == 1
Esempio n. 57
0
    def test_it_allows_group_scope_when_no_target_uri(self, annotation_data, pyramid_request, group_service, scoped_open_group):
        annotation_data.pop('target_uri')
        group_service.find.return_value = scoped_open_group

        # this should not raise
        annotation = storage.update_annotation(pyramid_request, 'test_annotation_id', annotation_data, group_service)

        assert annotation == pyramid_request.db.query.return_value.get.return_value
Esempio n. 58
0
    def test_it_allows_when_group_scope_matches(
        self, annotation_data, pyramid_request, group_service, scoped_open_group, models
    ):
        # This target URI matches at least one of the scopes for the group
        # it will go into...
        annotation_data["target_uri"] = "http://www.foo.com/baz/ding.html"

        # this should not raise
        annotation = storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, group_service
        )

        assert annotation == pyramid_request.db.query.return_value.get.return_value
Esempio n. 59
0
    def test_it_updates_the_document_metadata_from_the_annotation(
            self,
            annotation_data,
            session,
            datetime,
            update_document_metadata):
        annotation = session.query.return_value.get.return_value
        annotation_data['document']['document_meta_dicts'] = (
            mock.sentinel.document_meta_dicts)
        annotation_data['document']['document_uri_dicts'] = (
            mock.sentinel.document_uri_dicts)

        storage.update_annotation(session,
                                  'test_annotation_id',
                                  annotation_data)

        update_document_metadata.assert_called_once_with(
            session,
            annotation.target_uri,
            mock.sentinel.document_meta_dicts,
            mock.sentinel.document_uri_dicts,
            updated=datetime.utcnow()
        )
Esempio n. 60
0
    def test_it_allows_scope_mismatch_when_enforce_scope_is_False(
        self, annotation_data, pyramid_request, group_service, scoped_open_group
    ):
        scoped_open_group.enforce_scope = False
        group_service.find.return_value = scoped_open_group
        # This target URI is not within any of the group's defined scopes
        annotation_data["target_uri"] = "http://www.bar.com/baz/ding.html"

        # This will not raise because ``enforce_scope`` is set to False for the
        # annotation's group
        annotation = storage.update_annotation(
            pyramid_request, "test_annotation_id", annotation_data, group_service
        )

        assert annotation == pyramid_request.db.query.return_value.get.return_value