예제 #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)
예제 #2
0
파일: views_test.py 프로젝트: tilgovi/h
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)
예제 #3
0
파일: views_test.py 프로젝트: plainspace/h
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)
예제 #4
0
파일: views_test.py 프로젝트: ningyifan/h
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)
예제 #5
0
파일: views_test.py 프로젝트: tilgovi/h
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)
예제 #6
0
파일: views_test.py 프로젝트: linhua55/h
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)
예제 #7
0
def test_read_returns_annotation():
    context = mock.Mock()
    request = mock.Mock()

    result = views.read(context, request)

    assert result == context.model
예제 #8
0
파일: views_test.py 프로젝트: djcun95/h
    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()
예제 #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()
예제 #10
0
파일: views_test.py 프로젝트: hashin/h
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()
예제 #11
0
파일: views_test.py 프로젝트: tilgovi/h
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=[]))
예제 #12
0
파일: views_test.py 프로젝트: tilgovi/h
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
예제 #13
0
파일: views_test.py 프로젝트: ningyifan/h
def test_read_returns_rendered_annotation(search_lib):
    assert views.read(mock.Mock(),
                      mock.Mock()) == (search_lib.render.return_value)
예제 #14
0
파일: views_test.py 프로젝트: linhua55/h
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)
예제 #15
0
파일: views_test.py 프로젝트: plainspace/h
def test_read_returns_rendered_annotation(search_lib):
    assert views.read(mock.Mock(), mock.Mock()) == (
        search_lib.render.return_value)
예제 #16
0
파일: views_test.py 프로젝트: plainspace/h
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)
예제 #17
0
파일: views_test.py 프로젝트: linhua55/h
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
예제 #18
0
파일: views_test.py 프로젝트: ningyifan/h
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)
예제 #19
0
파일: views_test.py 프로젝트: linhua55/h
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=[]))