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
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)
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)
def tag_link(tag): tag = parser.unparse({"tag": tag}) return self.request.route_url("activity.search", _query=[("q", tag)])
def tag_link(tag): q = parser.unparse({'tag': tag}) return self.request.route_url('activity.search', _query=[('q', q)])
def tag_link(tag): q = parser.unparse({"tag": tag}) return self.request.route_url("activity.search", _query=[("q", q)])