Example #1
0
    def test_it_sets_correct_content_type(self, AnnotationJSONLDPresenter, pyramid_request):
        AnnotationJSONLDPresenter.CONTEXT_URL = 'http://foo.com/context.jsonld'

        annotation = mock.Mock()

        views.read_jsonld(annotation, pyramid_request)

        assert pyramid_request.response.content_type == 'application/ld+json'
        assert pyramid_request.response.content_type_params == {
            'profile': 'http://foo.com/context.jsonld'
        }
Example #2
0
    def test_it_sets_correct_content_type(self, AnnotationJSONLDPresenter, pyramid_request):
        AnnotationJSONLDPresenter.CONTEXT_URL = 'http://foo.com/context.jsonld'

        annotation = mock.Mock()

        views.read_jsonld(annotation, pyramid_request)

        assert pyramid_request.response.content_type == 'application/ld+json'
        assert pyramid_request.response.content_type_params == {
            'profile': 'http://foo.com/context.jsonld'
        }
Example #3
0
    def test_it_returns_presented_annotation(self, AnnotationJSONLDPresenter,
                                             pyramid_request):
        context = mock.Mock()
        presenter = mock.Mock()
        AnnotationJSONLDPresenter.return_value = presenter
        AnnotationJSONLDPresenter.CONTEXT_URL = 'http://foo.com/context.jsonld'

        result = views.read_jsonld(context, pyramid_request)

        AnnotationJSONLDPresenter.assert_called_once_with(context)
        assert result == presenter.asdict()
Example #4
0
    def test_it_returns_presented_annotation(self,
                                             AnnotationJSONLDPresenter,
                                             links_service,
                                             pyramid_request):
        annotation = mock.Mock()
        presenter = mock.Mock()
        AnnotationJSONLDPresenter.return_value = presenter
        AnnotationJSONLDPresenter.CONTEXT_URL = 'http://foo.com/context.jsonld'

        result = views.read_jsonld(annotation, pyramid_request)

        AnnotationJSONLDPresenter.assert_called_once_with(annotation,
                                                          links_service)
        assert result == presenter.asdict()