コード例 #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
コード例 #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']
コード例 #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)
コード例 #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
コード例 #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')