cryptonas-branches/pythonrewrite/bin2/exp.twilltest.CryptoBoxWebserverSites.py

56 lines
1.1 KiB
Python
Raw Normal View History

2006-09-05 02:15:43 +02:00
import twill
import cherrypy
import CryptoBoxWebserverSites
class TestIt:
'''this will be the testclass of the webserver, using "twill"
one way to manually run twill code is through the python
interpreter commandline e.g.:
import twill
twill.shell.main()
go http://localhost:8080
find "my very special html content"
help
'''
def setUp(self):
cherrypy.config.update({
'server.logToScreen' : True,
'autoreload.on': False,
'server.threadPool': 1,
'server.environment': 'production',
})
cherrypy.root = CryptoBoxWebserverSites.CryptoBoxWebserverSites()
from cherrypy._cpwsgi import wsgiApp
twill.add_wsgi_intercept('localhost', 8081, lambda: wsgiApp)
#output = open("foolog","w")
#twill.set_output(output)
def tearDown(self):
# remove intercept.
twill.remove_wsgi_intercept('localhost', 8081)
# shut down the cherrypy server.
cherrypy.server.stop()
#output.close()
def test_01(self):
twill.commands.go("http://localhost:8081/")
twill.commands.show()
if __name__ == "__main__":
t = TestIt()
t.setUp()
t.test_01()
t.tearDown()