File: test_cache_filter.py

package info (click to toggle)
python-cherrypy 2.2.1-3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 796 kB
  • ctags: 1,079
  • sloc: python: 7,869; makefile: 15
file content (40 lines) | stat: -rw-r--r-- 848 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import test
test.prefer_parent_path()

import cherrypy
import time


def setup_server():
    class Root:
        def __init__(self):
            cherrypy.counter = 0
        
        def index(self):
            cherrypy.counter += 1
            msg = "visit #%s" % cherrypy.counter
            return msg
        index.exposed = True

    cherrypy.root = Root()
    cherrypy.config.update({
            'server.log_to_screen': False,
            'server.environment': 'production',
            'cache_filter.on': True,
    })


import helper

class CacheFilterTest(helper.CPWebCase):
    
    def testCaching(self):
        for trial in xrange(10):
            self.getPage("/")
            # The response should be the same every time!
            self.assertBody('visit #1')

if __name__ == '__main__':
    setup_server()
    helper.testmain()