def test_default_redirect_unspecified_default(self): app = Flask(__name__) rule = '/temp/' map = {'google': 'http://google.com'} install_forwarder(app, rule, path_mapper=map.get) app = app.test_client() rv = app.get('/temp/doesnotexist', follow_redirects=False) self.assertEquals(rv.status_code, 302) self.assertEquals(rv.headers.get('Location'), 'http://localhost/temp/')
def test_simple_redirect(self): app = Flask(__name__) rule = '/temp/' map = {'google': 'http://google.com'} default_url = 'http://default.com' install_forwarder(app, rule, path_mapper=map.get, default_url=default_url) app = app.test_client() rv = app.get('/temp/google', follow_redirects=False) self.assertEquals(rv.status_code, 302) self.assertEquals(rv.headers.get('Location'), 'http://google.com')