Esempio n. 1
0
    def test_get_item_has_right_links_service(self, pyramid_request, storage,
                                              links_service):
        factory = AnnotationResourceFactory(pyramid_request)
        storage.fetch_annotation.return_value = mock.Mock()

        resource = factory['123']
        assert resource.links_service == links_service
Esempio n. 2
0
    def test_get_item_raises_when_annotation_is_not_found(
            self, storage, pyramid_request):
        factory = AnnotationResourceFactory(pyramid_request)
        storage.fetch_annotation.return_value = None

        with pytest.raises(KeyError):
            factory['123']
Esempio n. 3
0
    def test_get_item_returns_annotation_resource(self, pyramid_request,
                                                  storage):
        factory = AnnotationResourceFactory(pyramid_request)
        storage.fetch_annotation.return_value = mock.Mock()

        resource = factory['123']
        assert isinstance(resource, AnnotationResource)
Esempio n. 4
0
    def test_get_item_resource_has_right_annotation(self, pyramid_request,
                                                    storage):
        factory = AnnotationResourceFactory(pyramid_request)
        storage.fetch_annotation.return_value = mock.Mock()

        resource = factory['123']
        assert resource.annotation == storage.fetch_annotation.return_value
Esempio n. 5
0
    def test_get_item_fetches_annotation(self, pyramid_request, storage):
        factory = AnnotationResourceFactory(pyramid_request)

        factory['123']
        storage.fetch_annotation.assert_called_once_with(
            pyramid_request.db, '123')