コード例 #1
0
    def test_annotation_page_for(self):
        patron = self._patron()

        with self.app.test_request_context("/"):
            page = AnnotationWriter.annotation_page_for(patron)

            # The patron doesn't have any annotations, so the page is empty.
            eq_(AnnotationWriter.JSONLD_CONTEXT, page['@context'])
            assert 'annotations' in page['id']
            eq_('AnnotationPage', page['type'])
            eq_(0, len(page['items']))

            # If we add an annotation, the page will have an item.
            identifier = self._identifier()
            annotation, ignore = create(
                self._db, Annotation,
                patron=patron,
                identifier=identifier,
                motivation=Annotation.IDLING,
            )

            page = AnnotationWriter.annotation_page_for(patron)

            eq_(1, len(page['items']))

            # But if the annotation is deleted, the page will be empty again.
            annotation.active = False

            page = AnnotationWriter.annotation_page_for(patron)

            eq_(0, len(page['items']))
コード例 #2
0
    def test_annotation_page_for(self):
        patron = self._patron()

        with self.app.test_request_context("/"):
            page = AnnotationWriter.annotation_page_for(patron)

            # The patron doesn't have any annotations, so the page is empty.
            eq_(AnnotationWriter.JSONLD_CONTEXT, page['@context'])
            assert 'annotations' in page['id']
            eq_('AnnotationPage', page['type'])
            eq_(0, len(page['items']))

            # If we add an annotation, the page will have an item.
            identifier = self._identifier()
            annotation, ignore = create(
                self._db, Annotation,
                patron=patron,
                identifier=identifier,
                motivation=Annotation.IDLING,
            )

            page = AnnotationWriter.annotation_page_for(patron)

            eq_(1, len(page['items']))

            # But if the annotation is deleted, the page will be empty again.
            annotation.active = False

            page = AnnotationWriter.annotation_page_for(patron)

            eq_(0, len(page['items']))
コード例 #3
0
    def test_annotation_page_for(self):
        patron = self._patron()

        with self.app.test_request_context("/"):
            page = AnnotationWriter.annotation_page_for(patron)

            # The patron doesn't have any annotations, so the page is empty.
            assert AnnotationWriter.JSONLD_CONTEXT == page["@context"]
            assert "annotations" in page["id"]
            assert "AnnotationPage" == page["type"]
            assert 0 == len(page["items"])

            # If we add an annotation, the page will have an item.
            identifier = self._identifier()
            annotation, ignore = create(
                self._db,
                Annotation,
                patron=patron,
                identifier=identifier,
                motivation=Annotation.IDLING,
            )

            page = AnnotationWriter.annotation_page_for(patron)

            assert 1 == len(page["items"])

            # But if the annotation is deleted, the page will be empty again.
            annotation.active = False

            page = AnnotationWriter.annotation_page_for(patron)

            assert 0 == len(page["items"])