Ticket #1407: internal_redirect.patch

File internal_redirect.patch, 1.4 kB (added by simonk, 1 year ago)

Patch to test suite demonstrating problem with InternalRedirect?

  • tests/test_controllers.py

    old new  
    161161    flash_redirected = turbogears.expose(html=".simple", 
    162162        allow_json=True)(flash_redirected) 
    163163 
     164    def internal_redirect(self, **kwargs): 
     165        raise cherrypy.InternalRedirect('/internal_redirect_target') 
     166    internal_redirect = turbogears.expose()(internal_redirect) 
     167     
     168    def internal_redirect_target(self, **kwargs): 
     169        return "redirected OK" 
     170    internal_redirect_target = turbogears.expose()(internal_redirect_target) 
    164171 
    165172class TestRoot(unittest.TestCase): 
    166173    def setUp(self): 
     
    406413        assert not cherrypy.root.serve_exceptions 
    407414        #assert "AssertionError" not in outputcap.getvalue() 
    408415 
     416    def test_internal_redirect(self): 
     417        testutil.createRequest("/internal_redirect") 
     418        firstline = cherrypy.response.body[0] 
     419        assert "redirected OK" in firstline 
     420 
     421    def test_internal_redirect_nested_variables(self): 
     422        testutil.createRequest("/internal_redirect?a.b=1&a.c=2") 
     423        firstline = cherrypy.response.body[0] 
     424        print firstline 
     425        assert "redirected OK" in firstline 
     426             
     427 
     428 
    409429class TestURLs(unittest.TestCase): 
    410430    def setUp(self): 
    411431        cherrypy.tree.mount_points = {}