def test_convert_to_plain_object(self):
        """
        Converts search results to a plain Python object.
        """
        with app.test_request_context("/"):
            results = SearchIndex(bookmarks=get_bookmarks()).search("ap")

            presenter = SearchResultPresenter(results)

            result_list = presenter.to_list()

        self.assertGreater(len(result_list), 0)
Beispiel #2
0
    def bookmark_search():
        links = {
            'search.categories': uri_template(
                app, category_detail={'slug': 'search.categories'})
        }

        query_string = request.args.get('q', '')

        presenter = SearchResultPresenter(
            get_search_index().search(query_string))

        return make_response(
            jsonify({
                'links': links,
                'search': presenter.to_list()
            }),
            200,
            NO_CACHE_HEADERS)