예제 #1
0
    def test_it_presents_replies(self, pyramid_request, search_run, presentation_service):
        pyramid_request.params = {'_separate_replies': '1'}
        search_run.return_value = SearchResult(1, ['row-1'], ['reply-1', 'reply-2'], {})

        views.search(pyramid_request)

        presentation_service.present_all.assert_called_with(['reply-1', 'reply-2'])
예제 #2
0
파일: api_test.py 프로젝트: truthadjustr/h
    def test_it_presents_search_results(self, pyramid_request, search_run,
                                        presentation_service):
        search_run.return_value = SearchResult(2, ['row-1', 'row-2'], [], {})

        views.search(pyramid_request)

        presentation_service.present_all.assert_called_once_with(
            ['row-1', 'row-2'])
예제 #3
0
    def test_it_presents_search_results(self, pyramid_request, search_run,
                                        annotation_json_service):
        search_run.return_value = SearchResult(2, ["row-1", "row-2"], [], {})

        views.search(pyramid_request)

        annotation_json_service.present_all_for_user.assert_called_once_with(
            annotation_ids=["row-1", "row-2"], user=pyramid_request.user)
예제 #4
0
    def test_it_returns_search_results(
        self, pyramid_request, search_run, presentation_service
    ):
        search_run.return_value = SearchResult(2, ["row-1", "row-2"], [], {})

        expected = {"total": 2, "rows": presentation_service.present_all.return_value}

        assert views.search(pyramid_request) == expected
예제 #5
0
def search_run(search):
    from h.search.core import SearchResult
    result = SearchResult(total=123,
                          annotation_ids=['foo', 'bar'],
                          reply_ids=[],
                          aggregations={})
    search_run = search.Search.return_value.run
    search_run.return_value = result
    return search_run
예제 #6
0
    def test_it_returns_search_results(self, pyramid_request, search_run, presentation_service):
        search_run.return_value = SearchResult(2, ['row-1', 'row-2'], [], {})

        expected = {
            'total': 2,
            'rows': presentation_service.present_all.return_value
        }

        assert views.search(pyramid_request) == expected
예제 #7
0
    def test_it_presents_replies(
        self, pyramid_request, search_run, presentation_service
    ):
        pyramid_request.params = NestedMultiDict(MultiDict({"_separate_replies": "1"}))
        search_run.return_value = SearchResult(1, ["row-1"], ["reply-1", "reply-2"], {})

        views.search(pyramid_request)

        presentation_service.present_all.assert_called_with(["reply-1", "reply-2"])
예제 #8
0
def search_run(search):

    result = SearchResult(total=123,
                          annotation_ids=["foo", "bar"],
                          reply_ids=[],
                          aggregations={})
    search_run = search.Search.return_value.run
    search_run.return_value = result
    return search_run
예제 #9
0
    def test_it_returns_replies(self, pyramid_request, search_run, presentation_service):
        pyramid_request.params = {'_separate_replies': '1'}
        search_run.return_value = SearchResult(1, ['row-1'], ['reply-1', 'reply-2'], {})

        expected = {
            'total': 1,
            'rows': presentation_service.present_all(['row-1']),
            'replies': presentation_service.present_all(['reply-1', 'reply-2'])
        }

        assert views.search(pyramid_request) == expected
예제 #10
0
    def test_it_returns_replies(
        self, pyramid_request, search_run, presentation_service
    ):
        pyramid_request.params = NestedMultiDict(MultiDict({"_separate_replies": "1"}))
        search_run.return_value = SearchResult(1, ["row-1"], ["reply-1", "reply-2"], {})

        expected = {
            "total": 1,
            "rows": presentation_service.present_all(["row-1"]),
            "replies": presentation_service.present_all(["reply-1", "reply-2"]),
        }

        assert views.search(pyramid_request) == expected