Exemplo 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
Exemplo 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']
Exemplo 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)
Exemplo 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
Exemplo 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')