Exemple #1
0
 def make_builder():
     builder = query.Builder()
     builder.append_filter(query.AuthFilter(request, private=private))
     builder.append_filter(query.UriFilter())
     builder.append_filter(
         lambda _: nipsa.nipsa_filter(request.authenticated_userid))
     builder.append_filter(query.GroupFilter())
     builder.append_matcher(query.AnyMatcher())
     builder.append_matcher(query.TagsMatcher())
     return builder
Exemple #2
0
def test_anymatcher():
    anymatcher = query.AnyMatcher()

    result = anymatcher({"any": "foo"})

    assert result == {
        "simple_query_string": {
            "fields": ["quote", "tags", "text", "uri.parts", "user"],
            "query": "foo",
        }
    }
Exemple #3
0
def default_querybuilder(request, private=True):
    builder = query.Builder()
    builder.append_filter(query.AuthFilter(request, private=private))
    builder.append_filter(query.UriFilter(request))
    builder.append_filter(query.GroupFilter())
    builder.append_matcher(query.AnyMatcher())
    builder.append_matcher(query.TagsMatcher())
    for factory in request.registry.get(FILTERS_KEY, []):
        builder.append_filter(factory(request))
    for factory in request.registry.get(MATCHERS_KEY, []):
        builder.append_matcher(factory(request))
    return builder
Exemple #4
0
def test_anymatcher_multiple_params():
    """Multiple keywords at once are handled correctly."""
    anymatcher = query.AnyMatcher()
    params = multidict.MultiDict()
    params.add("any", "howdy")
    params.add("any", "there")

    result = anymatcher(params)

    assert result == {
        "simple_query_string": {
            "fields": ["quote", "tags", "text", "uri.parts", "user"],
            "query": "howdy there",
        }
    }