def test_location(): res = Response() res.location = '/test.html' eq_(res.location, '/test.html') req = Request.blank('/') eq_(req.get_response(res).location, 'http://localhost/test.html') res.location = '/test2.html' eq_(req.get_response(res).location, 'http://localhost/test2.html')
def test_location(): res = Response() res.location = '/test.html' assert res.location == '/test.html' req = Request.blank('/') assert req.get_response(res).location == 'http://localhost/test.html' res.location = '/test2.html' assert req.get_response(res).location == 'http://localhost/test2.html'
def test_location(): res = Response() res.location = '/test.html' eq_(res.location, '/test.html') req = Request.blank('/') eq_(req.get_response(res).location, 'http://localhost/test.html') res.location = '/test2.html' eq_(req.get_response(res).location, 'http://localhost/test2.html')
def test_location(): res = Response() res.location = "/test.html" eq_(res.location, "/test.html") req = Request.blank("/") eq_(req.get_response(res).location, "http://localhost/test.html") res.location = "/test2.html" eq_(req.get_response(res).location, "http://localhost/test2.html")
def test_location(): res = Response() res.status = "301" res.location = "/test.html" assert res.location == "/test.html" req = Request.blank("/") assert req.get_response(res).location == "http://localhost/test.html" res.location = "/test2.html" assert req.get_response(res).location == "http://localhost/test2.html"
def test_location(): res = Response() res.status = "301" res.location = "/test.html" assert res.location == "/test.html" req = Request.blank("/") assert req.get_response(res).location == "http://localhost/test.html" res.location = "/test2.html" assert req.get_response(res).location == "http://localhost/test2.html"
def __call__(self, req): results = self.map.routematch(environ=req.environ) if not results: return exc.HTTPNotFound() match, route = results link = URLGenerator(self.map, req.environ) if route.redirect: # Taken from the routes middleware module route_name = '_redirect_%s' % id(route) location = link(route_name, **match) # Build the response manually so we don't have to try to map the # route status to a specific webob exception redirect_response = Response(status=route.redirect_status) redirect_response.location = location return redirect_response match_controller = match.get('controller', None) if not callable(match_controller): log.error('Unsupported route match: %s', match) return exc.HTTPNotFound() req.urlvars = ((), match) req.link = link controller = match_controller(req, **self.config) return controller()
def test_location_unicode(): environ = { "REQUEST_METHOD": "GET", "wsgi.url_scheme": "http", "HTTP_HOST": u"test.com", } res = Response() res.status = "301" res.location = "/test.html" def start_response(status, headerlist): for (header, val) in headerlist: if header.lower() == "location": assert val == "http://test.com/test.html" assert isinstance(val, str) res(environ, start_response)
def test_location_unicode(): environ = { 'REQUEST_METHOD': 'GET', 'wsgi.url_scheme': 'http', 'HTTP_HOST': u'test.com', } res = Response() res.status = '301' res.location = '/test.html' def start_response(status, headerlist): for (header, val) in headerlist: if header.lower() == 'location': assert val == 'http://test.com/test.html' assert isinstance(val, str) res(environ, start_response)
def test_location_unicode(): environ = { "REQUEST_METHOD": "GET", "wsgi.url_scheme": "http", "HTTP_HOST": u"test.com", } res = Response() res.status = "301" res.location = "/test.html" def start_response(status, headerlist): for (header, val) in headerlist: if header.lower() == "location": assert val == "http://test.com/test.html" assert isinstance(val, str) res(environ, start_response)
def test_location_unicode(): environ = { 'REQUEST_METHOD': 'GET', 'wsgi.url_scheme': 'http', 'HTTP_HOST': u'test.com', } res = Response() res.status = '301' res.location = '/test.html' def start_response(status, headerlist): for (header, val) in headerlist: if header.lower() == 'location': assert val == 'http://test.com/test.html' assert isinstance(val, str) res(environ, start_response)