def test_found_headers(self): r = http.found("/", [("Set-Cookie", "name=value")]) # Pass through WebTest for lint-like checks webtest.TestApp(app.RestishApp(r)).get("/") # Test response details. assert r.headers["Location"] == "/" assert r.headers["Set-Cookie"] == "name=value"
def test_found_headers(self): r = http.found('/', [('Set-Cookie', 'name=value')]) # Pass through WebTest for lint-like checks webtest.TestApp(app.RestishApp(r)).get('/') # Test response details. assert r.headers['Location'] == '/' assert r.headers['Set-Cookie'] == 'name=value'
def test_found(self): location = "http://localhost/abc?a=1&b=2" r = http.found(location) # Pass through WebTest for lint-like checks webtest.TestApp(app.RestishApp(r)).get("/") # Test response details. assert r.status.startswith("302") assert r.headers["Location"] == location assert r.headers["Content-Length"] assert "302 Found" in r.body assert cgi.escape(location) in r.body
def test_found(self): location = 'http://localhost/abc?a=1&b=2' r = http.found(location) # Pass through WebTest for lint-like checks webtest.TestApp(app.RestishApp(r)).get('/') # Test response details. assert r.status.startswith('302') assert r.headers['Location'] == location assert r.headers['Content-Length'] assert '302 Found' in r.body assert cgi.escape(location) in r.body
def test_found_unicode(self): location = u'http://☃.net/' r = http.found(location) # Pass through WebTest for lint-like checks webtest.TestApp(app.RestishApp(r)).get('/') # Test response details. assert r.status.startswith('302') assert r.headers['Location'] == 'http://xn--n3h.net/' assert r.headers['Content-Length'] assert cgi.escape(location.encode("utf-8")) in r.body assert cgi.escape(url.URL(location)) in r.body
def decorator(func): # you cannot alter a variable that sits outside the scope # so they are renamed if to is None: dest = fro orig = func.__name__ else: dest = to orig = fro if type(dest) not in (list, tuple): dest = dest, # ignore original func new_func = lambda self, request, segments: http.found(request.application_url.child(*dest)) setattr(new_func, _RESTISH_CHILD, TemplateChildMatcher(orig)) return new_func
def html(self, request): return http.found("page")
def element(self, request): return http.found("element")
def func(self, request, segments, **kwargs): return http.found(request.application_url + to._url_for(kwargs))
def test_found(self): location = 'http://localhost/abc' r = http.found(location) assert r.status.startswith('302') assert r.headers['Location'] == location