示例#1
0
文件: views_test.py 项目: djcun95/h
    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'
        }
示例#2
0
    def test_it_sets_correct_content_type(self, AnnotationJSONLDPresenter):
        AnnotationJSONLDPresenter.CONTEXT_URL = 'http://foo.com/context.jsonld'

        annotation = mock.Mock()
        request = testing.DummyRequest()

        views.read_jsonld(annotation, request)

        assert request.response.content_type == 'application/ld+json'
        assert request.response.content_type_params == {
            'profile': 'http://foo.com/context.jsonld'
        }
示例#3
0
文件: views_test.py 项目: djcun95/h
    def test_it_returns_presented_annotation(self, AnnotationJSONLDPresenter, 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(pyramid_request, annotation)
        assert result == presenter.asdict()
示例#4
0
    def test_it_returns_presented_annotation(self, AnnotationJSONLDPresenter):
        annotation = mock.Mock()
        presenter = mock.Mock()
        AnnotationJSONLDPresenter.return_value = presenter
        AnnotationJSONLDPresenter.CONTEXT_URL = 'http://foo.com/context.jsonld'
        request = testing.DummyRequest()

        result = views.read_jsonld(annotation, request)

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