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

root/branches/cherrypy-2.x/cherrypy/test/test_logdebuginfo_filter.py

Revision 1017 (checked in by fumanchu, 3 years ago)

Initial fix for #498 (Test suite assumes same process for client and server). All test modules now wrap the server-side code in a "setup_server" function. New test\modpy module (with several tests failing).

  • Property svn:eol-style set to native
Line 
1 import test
2 test.prefer_parent_path()
3
4 import cherrypy
5
6
7 def setup_server():
8     class Root:
9         def index(self):
10             yield "Hello, world"
11         index.exposed = True
12
13         def bug326(self, file):
14             return "OK"
15         bug326.exposed = True
16
17     cherrypy.root = Root()
18
19     cherrypy.config.update({
20         'server.log_to_screen': False,
21         'server.environment': 'production',
22         'log_debug_info_filter.on': True,
23         '/bug326': {
24             'server.max_request_body_size': 300,
25             'server.environment': 'development',
26         }
27     })
28
29
30
31 import helper
32
33 class LogDebugInfoFilterTest(helper.CPWebCase):
34    
35     def testLogDebugInfoFilter(self):
36         self.getPage('/')
37         self.assertInBody('Build time')
38         self.assertInBody('Page size')
39         # not compatible with the session_filter
40         #self.assertInBody('Session data size')
41
42     def testBug326(self):
43         b = """--x
44 Content-Disposition: form-data; name="file"; filename="hello.txt"
45 Content-Type: text/plain
46
47 %s
48 --x--
49 """ % ("x" * 300)
50         h = [("Content-type", "multipart/form-data; boundary=x"),
51              ("Content-Length", len(b))]
52         self.getPage('/bug326', h, "POST", b)
53         self.assertStatus("413 Request Entity Too Large")
54
55
56 if __name__ == "__main__":
57     setup_server()
58     helper.testmain()
Note: See TracBrowser for help on using the browser.

Hosted by WebFaction

Log in as guest/cpguest to create tickets