Example #1
0
def test_read_404s_for_group_annotations_if_groups_feature_is_off():
    context = mock.Mock(model={'group': 'foo'})
    request = mock.Mock()
    request.feature.return_value = False

    with pytest.raises(httpexceptions.HTTPNotFound):
        views.read(context, request)
Example #2
0
def test_read_calls_render(search_lib):
    annotation = _mock_annotation()

    views.read(context=annotation,
               request=mock.Mock(effective_principals=[]))

    search_lib.render.assert_called_once_with(annotation.model)
Example #3
0
def test_read_event(AnnotationEvent):
    request = mock.Mock()
    annotation = mock.Mock()
    event = AnnotationEvent.return_value
    views.read(annotation, request)
    AnnotationEvent.assert_called_once_with(request, annotation, 'read')
    request.registry.notify.assert_called_once_with(event)
Example #4
0
def test_read_event(AnnotationEvent):
    request = mock.Mock()
    annotation = mock.Mock()
    event = AnnotationEvent.return_value
    views.read(annotation, request)
    AnnotationEvent.assert_called_once_with(request, annotation, 'read')
    request.registry.notify.assert_called_once_with(event)
Example #5
0
def test_read_event(AnnotationEvent):
    annotation = _mock_annotation()
    request = mock.Mock(effective_principals=[])
    event = AnnotationEvent.return_value

    views.read(annotation, request)

    AnnotationEvent.assert_called_once_with(request, annotation.model, 'read')
    request.registry.notify.assert_called_once_with(event)
Example #6
0
def test_read_event(AnnotationEvent):
    annotation = _mock_annotation()
    request = mock.Mock(effective_principals=[])
    event = AnnotationEvent.return_value

    views.read(annotation, request)

    AnnotationEvent.assert_called_once_with(request, annotation.model, 'read')
    request.registry.notify.assert_called_once_with(event)
Example #7
0
def test_read_returns_annotation():
    context = mock.Mock()
    request = mock.Mock()

    result = views.read(context, request)

    assert result == context.model
Example #8
0
    def test_it_returns_presented_annotation(self, AnnotationJSONPresenter, pyramid_request):
        annotation = mock.Mock()
        presenter = mock.Mock()
        AnnotationJSONPresenter.return_value = presenter

        result = views.read(annotation, pyramid_request)

        AnnotationJSONPresenter.assert_called_once_with(pyramid_request, annotation)
        assert result == presenter.asdict()
Example #9
0
def test_read_returns_presented_annotation(AnnotationJSONPresenter):
    annotation = mock.Mock()
    request = mock.Mock()
    presenter = mock.Mock()
    AnnotationJSONPresenter.return_value = presenter

    result = views.read(annotation, request)

    AnnotationJSONPresenter.assert_called_once_with(annotation)
    assert result == presenter.asdict()
Example #10
0
def test_read_returns_presented_annotation(AnnotationJSONPresenter):
    annotation = mock.Mock()
    request = mock.Mock()
    presenter = mock.Mock()
    AnnotationJSONPresenter.return_value = presenter

    result = views.read(annotation, request)

    AnnotationJSONPresenter.assert_called_once_with(annotation)
    assert result == presenter.asdict()
Example #11
0
def test_read_does_not_crash_if_annotation_has_no_group():
    annotation = _mock_annotation()
    assert 'group' not in annotation

    views.read(annotation, mock.Mock(effective_principals=[]))
Example #12
0
def test_read_returns_rendered_annotation(search_lib):
    response_data = views.read(
        _mock_annotation(),
        mock.Mock(effective_principals=[]))

    assert response_data == search_lib.render.return_value
Example #13
0
def test_read_returns_rendered_annotation(search_lib):
    assert views.read(mock.Mock(),
                      mock.Mock()) == (search_lib.render.return_value)
Example #14
0
def test_read_calls_render(search_lib):
    annotation = _mock_annotation()

    views.read(context=annotation, request=mock.Mock(effective_principals=[]))

    search_lib.render.assert_called_once_with(annotation.model)
Example #15
0
def test_read_returns_rendered_annotation(search_lib):
    assert views.read(mock.Mock(), mock.Mock()) == (
        search_lib.render.return_value)
Example #16
0
def test_read_calls_render(search_lib):
    annotation = mock.Mock()

    views.read(context=annotation, request=mock.Mock())

    search_lib.render.assert_called_once_with(annotation)
Example #17
0
def test_read_returns_rendered_annotation(search_lib):
    response_data = views.read(_mock_annotation(),
                               mock.Mock(effective_principals=[]))

    assert response_data == search_lib.render.return_value
Example #18
0
def test_read_calls_render(search_lib):
    annotation = mock.Mock()

    views.read(context=annotation, request=mock.Mock())

    search_lib.render.assert_called_once_with(annotation)
Example #19
0
def test_read_does_not_crash_if_annotation_has_no_group():
    annotation = _mock_annotation()
    assert 'group' not in annotation

    views.read(annotation, mock.Mock(effective_principals=[]))