diff --git a/pythonrewrite/bin2/CryptoBoxWebserver.py b/pythonrewrite/bin2/CryptoBoxWebserver.py index eea7ce5..2f645bf 100755 --- a/pythonrewrite/bin2/CryptoBoxWebserver.py +++ b/pythonrewrite/bin2/CryptoBoxWebserver.py @@ -30,6 +30,7 @@ class CryptoBoxWebserver: ''' def start(self): + # just use this config, when we're startet directly cherrypy.config.update(file = "cryptoboxwebserver.conf") cherrypy.server.start() diff --git a/pythonrewrite/bin2/CryptoBoxWebserverSites.py b/pythonrewrite/bin2/CryptoBoxWebserverSites.py index fcec73e..abd4c38 100755 --- a/pythonrewrite/bin2/CryptoBoxWebserverSites.py +++ b/pythonrewrite/bin2/CryptoBoxWebserverSites.py @@ -170,6 +170,9 @@ class CryptoBoxWebserverSites(CryptoBox.CryptoBoxProps, CryptoBoxWebserverSettin self.__prepare("show_status") return website.render(self) + def test(self): + return "test passed" + def umount_do(self): if not __isHDAvailable(): pass @@ -233,5 +236,6 @@ class CryptoBoxWebserverSites(CryptoBox.CryptoBoxProps, CryptoBoxWebserverSettin logs.exposed = True system.exposed = True status.exposed = True + test.exposed = True diff --git a/pythonrewrite/bin2/exp.twilltest.CryptoBoxWebserverSites.py b/pythonrewrite/bin2/exp.twilltest.CryptoBoxWebserverSites.py new file mode 100644 index 0000000..ede66c3 --- /dev/null +++ b/pythonrewrite/bin2/exp.twilltest.CryptoBoxWebserverSites.py @@ -0,0 +1,55 @@ +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() + +