Ejemplo n.º 1
0
def test_search_factory_without_query(base_app):
    with base_app.test_request_context(""):
        search = InspireSearch()
        expected_query_string = ""
        expected_search_to_dict = {"query": {"match_all": {}}}
        query_string, search = inspire_search_factory(None, search)
        search_to_dict = search.to_dict()

        assert expected_query_string == query_string
        assert expected_search_to_dict == search_to_dict
Ejemplo n.º 2
0
def test_search_factory_without_query(inspire_app):
    with current_app.test_request_context(""):
        search = InspireSearch()
        expected_query_string = ""
        expected_search_to_dict = {
            "query": {
                "match_all": {}
            },
            "track_total_hits": True
        }
        query_string, search = inspire_search_factory(None, search)
        search_to_dict = search.to_dict()

        assert expected_query_string == query_string
        assert expected_search_to_dict == search_to_dict
Ejemplo n.º 3
0
def test_search_factory_with_query(inspire_app):
    with current_app.test_request_context("?q=foo"):
        search = InspireSearch()
        expected_query_string = "foo"
        expected_search_to_dict = {
            "query": {
                "query_string": {
                    "default_operator": "AND",
                    "query": "foo"
                }
            },
            "track_total_hits": True,
        }
        query_string, search = inspire_search_factory(None, search)
        search_to_dict = search.to_dict()

        assert expected_query_string == query_string
        assert expected_search_to_dict == search_to_dict