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'])
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'])
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)
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
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
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
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"])
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
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
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