Example #1
0
 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"
Example #2
0
 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'
Example #3
0
 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'
Example #4
0
 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
Example #5
0
 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
Example #6
0
 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
Example #7
0
 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
Example #8
0
        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
Example #9
0
 def html(self, request):
     return http.found("page")
Example #10
0
 def element(self, request):
     return http.found("element")
Example #11
0
 def func(self, request, segments, **kwargs):
     return http.found(request.application_url + to._url_for(kwargs))
Example #12
0
 def test_found(self):
     location = 'http://localhost/abc'
     r = http.found(location)
     assert r.status.startswith('302')
     assert r.headers['Location'] == location