Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/cherrypy/test/test_wsgi_vhost.py
diff options
context:
space:
mode:
Diffstat (limited to 'cherrypy/test/test_wsgi_vhost.py')
-rwxr-xr-xcherrypy/test/test_wsgi_vhost.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/cherrypy/test/test_wsgi_vhost.py b/cherrypy/test/test_wsgi_vhost.py
new file mode 100755
index 0000000..abb1a91
--- /dev/null
+++ b/cherrypy/test/test_wsgi_vhost.py
@@ -0,0 +1,36 @@
+import cherrypy
+from cherrypy.test import helper
+
+
+class WSGI_VirtualHost_Test(helper.CPWebCase):
+
+ def setup_server():
+
+ class ClassOfRoot(object):
+
+ def __init__(self, name):
+ self.name = name
+
+ def index(self):
+ return "Welcome to the %s website!" % self.name
+ index.exposed = True
+
+
+ default = cherrypy.Application(None)
+
+ domains = {}
+ for year in range(1997, 2008):
+ app = cherrypy.Application(ClassOfRoot('Class of %s' % year))
+ domains['www.classof%s.example' % year] = app
+
+ cherrypy.tree.graft(cherrypy._cpwsgi.VirtualHost(default, domains))
+ setup_server = staticmethod(setup_server)
+
+ def test_welcome(self):
+ if not cherrypy.server.using_wsgi:
+ return self.skip("skipped (not using WSGI)... ")
+
+ for year in range(1997, 2008):
+ self.getPage("/", headers=[('Host', 'www.classof%s.example' % year)])
+ self.assertBody("Welcome to the Class of %s website!" % year)
+