cryptonas-branches/pythonrewrite/bin/unittests.WebSites.py

56 lines
1.4 KiB
Python
Raw Normal View History

#!/usr/bin/env python2.4
import unittest
## this makes assertRaises shorter
from twill.errors import *
from mechanize import BrowserStateError, LinkNotFoundError
## import the module of the common super class of all web interface test classes
import WebInterfaceTestClass
class WebServer(WebInterfaceTestClass.WebInterfaceTestClass):
def test_is_server_running(self):
'''the server should run under given name and port'''
self.cmd.go(self.URL)
## other URLs must not be checked, as we do not know, if they are valid
class BuiltinPages(WebInterfaceTestClass.WebInterfaceTestClass):
def test_help_pages(self):
'''help pages should be available in different languages'''
## check english help pages
self.cmd.go(self.URL + "doc?weblang=en")
self.cmd.find("Table of Contents")
self.cmd.find("Getting started")
self.cmd.go(self.URL + "doc?weblang=de")
self.cmd.find("Table of Contents")
self.cmd.find("Wie geht es los")
self.cmd.go(self.URL + "doc?weblang=si")
self.assertRaises(TwillAssertionError, self.cmd.notfind, "Table of Contents")
#TODO: add a slovene text here, as soon as the help is translated
def test_goto_status(self):
'''display all active devices'''
self.cmd.go(self.URL + "status")
self.cmd.find("Status")
def test_goto_system(self):
self.cmd.go(self.URL + "system")
self.cmd.find("System")
if __name__ == "__main__":
unittest.main()