File: test_baseurl_filter.py

package info (click to toggle)
python-cherrypy 2.2.1-3etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 804 kB
  • ctags: 1,079
  • sloc: python: 7,869; makefile: 15
file content (34 lines) | stat: -rw-r--r-- 775 bytes parent folder | download | duplicates (5)
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
import test
test.prefer_parent_path()

import cherrypy


def setup_server():
    class Root:
        def index(self):
            raise cherrypy.HTTPRedirect('dummy')
        index.exposed = True
    
    cherrypy.tree.mount(Root())
    cherrypy.config.update({
            'server.environment': 'production',
            'server.log_to_screen': False,
            'base_url_filter.on': True,
            'base_url_filter.base_url': 'http://www.mydomain.com'
    })


import helper

class BaseUrlFilterTest(helper.CPWebCase):
    
    def testBaseUrlFilter(self):
        self.getPage("/")
        self.assertHeader('Location',
                          "http://www.mydomain.com%s/dummy" % self.prefix())


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