Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #819: python-cherrypy-wsgi-819-test.patch

Line 
1 Patch to test for http://www.cherrypy.org/ticket/819
2
3 --- cherrypy/test/test_wsgiapps.py.orig 2008-05-17 22:34:23.000000000 +0200
4 +++ cherrypy/test/test_wsgiapps.py      2008-05-23 09:25:03.000000000 +0200
5 @@ -1,3 +1,4 @@
6 +import cherrypy
7  from cherrypy.test import test
8  test.prefer_parent_path()
9  
10 @@ -26,7 +27,13 @@
11          start_response(status, response_headers)
12          return ['Hello', '', ' ', '', 'world']
13      
14 -   
15 +    def test_post_error_app(environ, start_response):
16 +        status = '500 Method Not Implemented'
17 +        response_headers = [('Content-type', 'text/plain')]
18 +        start_response(status, response_headers)
19 +        return ["The server encountered an unexpected condition ",
20 +                  "which prevented it from fulfilling the request."]
21 +       
22      class WSGIResponse(object):
23          
24          def __init__(self, appresults):
25 @@ -69,6 +76,7 @@
26     
27      cherrypy.tree.graft(test_app, '/hosted/app1')
28      cherrypy.tree.graft(test_empty_string_app, '/hosted/app3')
29 +    cherrypy.tree.graft(test_post_error_app, '/hosted/app4')
30     
31      # Set script_name explicitly to None to signal CP that it should
32      # be pulled from the WSGI environ each time.
33 @@ -104,7 +112,21 @@
34          self.assertHeader("Content-Type", "text/plain")
35          self.assertInBody('Hello world')
36  
37 +    def test_07_post_error(self):
38 +        self.set_persistent(True)
39 +        self.getPage("/hosted/app4", method="POST", body="name=Bob\r\n")
40 +        self.assertStatus(500)
41 +        self.assertInBody("The server encountered an unexpected condition "
42 +                  "which prevented it from fulfilling the request.")
43 +        # now check that the content body got read correctly
44 +        self.getPage("/hosted/app3")
45 +        self.assertHeader("Content-Type", "text/plain")
46 +        self.assertInBody('Hello world')
47 +       
48  if __name__ == '__main__':
49      setup_server()
50 +    cherrypy.config.update({
51 +        'server.max_request_body_size': 0,
52 +        })
53      helper.testmain()
54  

Hosted by WebFaction

Log in as guest/cpguest to create tickets