コード例 #1
0
ファイル: views_test.py プロジェクト: plainspace/h
def test_annotations_index_calls_feature():
    """It should call request.feature() once, passing 'search_normalized'."""
    request = mock.Mock()

    views.annotations_index(request)

    request.feature.assert_called_once_with('search_normalized')
コード例 #2
0
ファイル: views_test.py プロジェクト: ningyifan/h
def test_annotations_index_calls_feature():
    """It should call request.feature() once, passing 'search_normalized'."""
    request = mock.Mock()

    views.annotations_index(request)

    request.feature.assert_called_once_with('search_normalized')
コード例 #3
0
ファイル: views_test.py プロジェクト: plainspace/h
def test_annotations_index_calls_get_user(get_user):
    """It should call get_user() once passing the request."""
    request = mock.Mock()

    views.annotations_index(request)

    get_user.assert_called_once_with(request)
コード例 #4
0
ファイル: views_test.py プロジェクト: ningyifan/h
def test_annotations_index_calls_get_user(get_user):
    """It should call get_user() once passing the request."""
    request = mock.Mock()

    views.annotations_index(request)

    get_user.assert_called_once_with(request)
コード例 #5
0
ファイル: views_test.py プロジェクト: plainspace/h
def test_annotations_index_passes_search_normalized_uris(search_lib):
    """It should pass search_normalized from request.feature() to index()."""
    request = mock.Mock()

    views.annotations_index(request)

    assert search_lib.index.call_args[1]['search_normalized_uris'] == (
        request.feature.return_value)
コード例 #6
0
ファイル: views_test.py プロジェクト: ningyifan/h
def test_annotations_index_passes_search_normalized_uris(search_lib):
    """It should pass search_normalized from request.feature() to index()."""
    request = mock.Mock()

    views.annotations_index(request)

    assert search_lib.index.call_args[1]['search_normalized_uris'] == (
        request.feature.return_value)
コード例 #7
0
ファイル: views_test.py プロジェクト: ningyifan/h
def test_annotations_index_returns_total(search_lib):
    """It should return the total from search_lib.index()."""
    search_lib.index.return_value = {
        'total': 3,
        # In production these would be annotation dicts, not strings.
        'rows': ['annotation_1', 'annotation_2', 'annotation_3']
    }

    response_data = views.annotations_index(mock.Mock())

    assert response_data['total'] == 3
コード例 #8
0
ファイル: views_test.py プロジェクト: plainspace/h
def test_annotations_index_returns_total(search_lib):
    """It should return the total from search_lib.index()."""
    search_lib.index.return_value = {
        'total': 3,
        # In production these would be annotation dicts, not strings.
        'rows': ['annotation_1', 'annotation_2', 'annotation_3']
    }

    response_data = views.annotations_index(mock.Mock())

    assert response_data['total'] == 3
コード例 #9
0
ファイル: views_test.py プロジェクト: linhua55/h
def test_annotations_index_renders_results(search_lib):
    request = testing.DummyRequest()
    search_lib.search.return_value = {
        'total': 3,
        'rows': ['a', 'b', 'c'],
    }
    search_lib.render.side_effect = lambda x: x.upper()

    result = views.annotations_index(request)

    assert result == {
        'total': 3,
        'rows': ['A', 'B', 'C'],
    }
コード例 #10
0
ファイル: views_test.py プロジェクト: tilgovi/h
def test_annotations_index_renders_results(search_lib):
    request = testing.DummyRequest()
    search_lib.search.return_value = {
        'total': 3,
        'rows': ['a', 'b', 'c'],
    }
    search_lib.render.side_effect = lambda x: x.upper()

    result = views.annotations_index(request)

    assert result == {
        'total': 3,
        'rows': ['A', 'B', 'C'],
    }
コード例 #11
0
ファイル: views_test.py プロジェクト: plainspace/h
def test_annotations_index_returns_rendered_annotations(search_lib):
    """It should return the rendered annotations.

    It should pass the annotations from search_lib.index() through
    search_lib.render() and return the results.

    """
    search_lib.index.return_value = {
        'total': 3,
        # In production these would be annotation dicts, not strings.
        'rows': ['annotation_1', 'annotation_2', 'annotation_3']
    }
    # Our mock render function just appends '_rendered' onto our mock
    # annotation strings.
    search_lib.render.side_effect = lambda annotation: annotation + '_rendered'

    response_data = views.annotations_index(mock.Mock())

    assert response_data['rows'] == [
        'annotation_1_rendered', 'annotation_2_rendered',
        'annotation_3_rendered']
コード例 #12
0
ファイル: views_test.py プロジェクト: ningyifan/h
def test_annotations_index_returns_rendered_annotations(search_lib):
    """It should return the rendered annotations.

    It should pass the annotations from search_lib.index() through
    search_lib.render() and return the results.

    """
    search_lib.index.return_value = {
        'total': 3,
        # In production these would be annotation dicts, not strings.
        'rows': ['annotation_1', 'annotation_2', 'annotation_3']
    }
    # Our mock render function just appends '_rendered' onto our mock
    # annotation strings.
    search_lib.render.side_effect = lambda annotation: annotation + '_rendered'

    response_data = views.annotations_index(mock.Mock())

    assert response_data['rows'] == [
        'annotation_1_rendered', 'annotation_2_rendered',
        'annotation_3_rendered'
    ]
コード例 #13
0
ファイル: views_test.py プロジェクト: chr7stos/Webmarks
def test_annotations_index_returns_search_results(search_lib):
    request = testing.DummyRequest()

    result = views.annotations_index(request)

    assert result == search_lib.search.return_value
コード例 #14
0
ファイル: views_test.py プロジェクト: tilgovi/h
def test_annotations_index_searches(search_lib):
    request = testing.DummyRequest()

    views.annotations_index(request)

    search_lib.search.assert_called_once_with(request, {"limit": 20})
コード例 #15
0
ファイル: views_test.py プロジェクト: ningyifan/h
def test_annotations_index_passes_user_to_index(get_user, search_lib):
    """It should pass the user from get_user() to search_lib.index()."""
    views.annotations_index(mock.Mock())

    assert search_lib.index.call_args[1]['user'] == get_user.return_value
コード例 #16
0
ファイル: views_test.py プロジェクト: linhua55/h
def test_annotations_index_searches(search_lib):
    request = testing.DummyRequest()

    views.annotations_index(request)

    search_lib.search.assert_called_once_with(request, {"limit": 20})
コード例 #17
0
ファイル: views_test.py プロジェクト: plainspace/h
def test_annotations_index_passes_user_to_index(get_user, search_lib):
    """It should pass the user from get_user() to search_lib.index()."""
    views.annotations_index(mock.Mock())

    assert search_lib.index.call_args[1]['user'] == get_user.return_value
コード例 #18
0
ファイル: views_test.py プロジェクト: plainspace/h
def test_annotations_index_calls_index(search_lib):
    """It should call search_lib.index() once."""
    views.annotations_index(mock.Mock())

    assert search_lib.index.call_count == 1
コード例 #19
0
ファイル: views_test.py プロジェクト: ningyifan/h
def test_annotations_index_calls_index(search_lib):
    """It should call search_lib.index() once."""
    views.annotations_index(mock.Mock())

    assert search_lib.index.call_count == 1