示例#1
0
    def test_updated_returns_none_if_missing(self):
        annotation = mock.Mock(updated=None)
        resource = mock.Mock(annotation=annotation)

        updated = AnnotationBasePresenter(resource).updated

        assert updated is None
示例#2
0
    def test_updated_returns_none_if_missing(self, fake_links_service):
        annotation = mock.Mock(updated=None)

        updated = AnnotationBasePresenter(annotation,
                                          fake_links_service).updated

        assert updated is None
示例#3
0
    def test_updated_uses_iso_format(self, fake_links_service):
        when = datetime.datetime(1983, 8, 31, 7, 18, 20, 98763)
        annotation = mock.Mock(updated=when)

        updated = AnnotationBasePresenter(annotation,
                                          fake_links_service).updated

        assert updated == '1983-08-31T07:18:20.098763+00:00'
示例#4
0
    def test_created_uses_iso_format(self, fake_links_service):
        when = datetime.datetime(2012, 3, 14, 23, 34, 47, 12)
        annotation = mock.Mock(created=when)

        created = AnnotationBasePresenter(annotation,
                                          fake_links_service).created

        assert created == '2012-03-14T23:34:47.000012+00:00'
示例#5
0
    def test_constructor_args(self):
        annotation = mock.Mock()
        resource = mock.Mock(annotation=annotation)

        presenter = AnnotationBasePresenter(resource)

        assert presenter.annotation_resource == resource
        assert presenter.annotation == annotation
示例#6
0
    def test_target_missing_selectors(self):
        annotation = mock.Mock(target_uri='http://example.com',
                               target_selectors=None)
        resource = mock.Mock(annotation=annotation)

        expected = [{'source': 'http://example.com'}]
        actual = AnnotationBasePresenter(resource).target
        assert expected == actual
示例#7
0
    def test_links(self, fake_links_service):
        annotation = mock.Mock()

        links = AnnotationBasePresenter(annotation, fake_links_service).links

        assert links == {
            'giraffe': 'http://giraffe.com',
            'toad': 'http://toad.net'
        }
示例#8
0
    def test_target(self, fake_links_service):
        ann = mock.Mock(
            target_uri='http://example.com',
            target_selectors={'PositionSelector': {
                'start': 0,
                'end': 12
            }})

        expected = [{
            'source': 'http://example.com',
            'selector': {
                'PositionSelector': {
                    'start': 0,
                    'end': 12
                }
            }
        }]
        actual = AnnotationBasePresenter(ann, fake_links_service).target
        assert expected == actual
示例#9
0
    def test_links_passes_annotation(self, fake_links_service):
        annotation = mock.Mock()

        links = AnnotationBasePresenter(annotation, fake_links_service).links

        assert fake_links_service.last_annotation == annotation
示例#10
0
    def test_tags(self, fake_links_service):
        ann = mock.Mock(tags=['interesting', 'magic'])
        presenter = AnnotationBasePresenter(ann, fake_links_service)

        assert ['interesting', 'magic'] == presenter.tags
示例#11
0
    def test_tags_missing(self):
        annotation = mock.Mock(tags=None)
        resource = mock.Mock(annotation=annotation)
        presenter = AnnotationBasePresenter(resource)

        assert [] == presenter.tags
示例#12
0
    def test_tags(self):
        annotation = mock.Mock(tags=['interesting', 'magic'])
        resource = mock.Mock(annotation=annotation)
        presenter = AnnotationBasePresenter(resource)

        assert ['interesting', 'magic'] == presenter.tags
示例#13
0
    def test_text_missing(self):
        annotation = mock.Mock(text=None)
        resource = mock.Mock(annotation=annotation)
        presenter = AnnotationBasePresenter(resource)

        assert '' == presenter.text
示例#14
0
    def test_text(self):
        annotation = mock.Mock(text='It is magical!')
        resource = mock.Mock(annotation=annotation)
        presenter = AnnotationBasePresenter(resource)

        assert 'It is magical!' == presenter.text
示例#15
0
    def test_links(self):
        annotation = mock.Mock()
        resource = mock.Mock(annotation=annotation)

        links = AnnotationBasePresenter(resource).links
        assert links == resource.links
示例#16
0
    def test_text(self, fake_links_service):
        ann = mock.Mock(text='It is magical!')
        presenter = AnnotationBasePresenter(ann, fake_links_service)

        assert 'It is magical!' == presenter.text
示例#17
0
    def test_text_missing(self, fake_links_service):
        ann = mock.Mock(text=None)
        presenter = AnnotationBasePresenter(ann, fake_links_service)

        assert '' == presenter.text
示例#18
0
    def test_target_missing_selectors(self, fake_links_service):
        ann = mock.Mock(target_uri='http://example.com', target_selectors=None)

        expected = [{'source': 'http://example.com'}]
        actual = AnnotationBasePresenter(ann, fake_links_service).target
        assert expected == actual
示例#19
0
    def test_tags_missing(self, fake_links_service):
        ann = mock.Mock(tags=None)
        presenter = AnnotationBasePresenter(ann, fake_links_service)

        assert [] == presenter.tags
示例#20
0
    def test_constructor_args(self, fake_links_service):
        annotation = mock.Mock()

        presenter = AnnotationBasePresenter(annotation, fake_links_service)

        assert presenter.annotation == annotation