def test_unparse(query):
    result = parser.unparse(query)

    # We can't trivially test that the output is exactly what we expect,
    # because of uncertainty in the ordering of keys. Instead, we check that
    # parsing the result gives us an object equal to the original query.
    assert parser.parse(result) == query
Beispiel #2
0
def test_unparse(query):
    result = parser.unparse(query)

    # We can't trivially test that the output is exactly what we expect,
    # because of uncertainty in the ordering of keys. Instead, we check that
    # parsing the result gives us an object equal to the original query.
    assert parser.parse(result) == query
Beispiel #3
0
def _update_q(params, parsed_query):
    """
    Update the given request params based on the given parsed_query.

    Update the value of the 'q' string in the given request params based on the
    given parsed_query.

    If the query parses to an empty string then ensure that there is no 'q' in
    the given request params, to avoid redirecting the browser to a URL with an
    empty trailing ?q=

    """
    query_ = parser.unparse(parsed_query)
    if query_.strip():
        params["q"] = query_
    else:
        params.pop("q", None)
Beispiel #4
0
def _update_q(params, parsed_query):
    """
    Update the given request params based on the given parsed_query.

    Update the value of the 'q' string in the given request params based on the
    given parsed_query.

    If the query parses to an empty string then ensure that there is no 'q' in
    the given request params, to avoid redirecting the browser to a URL with an
    empty trailing ?q=

    """
    q = parser.unparse(parsed_query)
    if q.strip():
        params['q'] = q
    else:
        params.pop('q', None)
Beispiel #5
0
 def tag_link(tag):
     tag = parser.unparse({"tag": tag})
     return self.request.route_url("activity.search",
                                   _query=[("q", tag)])
Beispiel #6
0
 def tag_link(tag):
     q = parser.unparse({'tag': tag})
     return self.request.route_url('activity.search', _query=[('q', q)])
Beispiel #7
0
 def tag_link(tag):
     q = parser.unparse({'tag': tag})
     return self.request.route_url('activity.search', _query=[('q', q)])
Beispiel #8
0
 def tag_link(tag):
     q = parser.unparse({"tag": tag})
     return self.request.route_url("activity.search", _query=[("q", q)])