コード例 #1
0
ファイル: presenters_test.py プロジェクト: ssin122/test-h
    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
ファイル: presenters_test.py プロジェクト: ssin122/test-h
    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
ファイル: presenters_test.py プロジェクト: ssin122/test-h
    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
ファイル: presenters_test.py プロジェクト: ssin122/test-h
    def test_tags_missing(self):
        annotation = mock.Mock(tags=None)
        resource = mock.Mock(annotation=annotation)
        presenter = AnnotationBasePresenter(resource)

        assert [] == presenter.tags
コード例 #12
0
ファイル: presenters_test.py プロジェクト: ssin122/test-h
    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
ファイル: presenters_test.py プロジェクト: ssin122/test-h
    def test_text_missing(self):
        annotation = mock.Mock(text=None)
        resource = mock.Mock(annotation=annotation)
        presenter = AnnotationBasePresenter(resource)

        assert '' == presenter.text
コード例 #14
0
ファイル: presenters_test.py プロジェクト: ssin122/test-h
    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
ファイル: presenters_test.py プロジェクト: ssin122/test-h
    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