twill experiments
This commit is contained in:
parent
1ff4bd59fb
commit
0a8fc07556
1 changed files with 31 additions and 2 deletions
|
@ -15,7 +15,7 @@ from mechanize import BrowserStateError, LinkNotFoundError
|
|||
## commands api: http://twill.idyll.org/commands.html
|
||||
cbx = twill.commands
|
||||
CBXHOST="localhost"
|
||||
CBXPORT=8080
|
||||
CBXPORT=8081
|
||||
CBX="http://"+CBXHOST+":"+str(CBXPORT)
|
||||
|
||||
class WebserverTests(unittest.TestCase):
|
||||
|
@ -62,6 +62,11 @@ class WebserverTests(unittest.TestCase):
|
|||
cherrypy.server.stop()
|
||||
self.output.close()
|
||||
|
||||
def __get_soup():
|
||||
from twill.commands import get_browser
|
||||
browser = get_browser()
|
||||
soup = BeautifulSoup(browser.get_html())
|
||||
return soup
|
||||
|
||||
########################################
|
||||
######## the tests start here ##########
|
||||
|
@ -90,10 +95,10 @@ class WebserverTests(unittest.TestCase):
|
|||
cbx.find("Wie geht es los")
|
||||
|
||||
cbx.go("doc?weblang=si")
|
||||
#TODO: if weblang=si no help is displayed at all
|
||||
self.assertRaises(TwillAssertionError, cbx.notfind, "Table of Contents")
|
||||
|
||||
def test_goto_status(self):
|
||||
'''display all active devices'''
|
||||
cbx.go(CBX)
|
||||
cbx.go("status")
|
||||
cbx.find("Status")
|
||||
|
@ -103,9 +108,33 @@ class WebserverTests(unittest.TestCase):
|
|||
cbx.go("system")
|
||||
cbx.find("System")
|
||||
cbx.notfind("Sstem")
|
||||
cbx.show()
|
||||
self.assertRaises(TwillAssertionError, cbx.find, "Sstem")
|
||||
self.assertRaises(TwillAssertionError, cbx.notfind, "System")
|
||||
|
||||
def test_plugin_network(self):
|
||||
'''change of network address'''
|
||||
import socket
|
||||
# actIP assumes working nameservice
|
||||
actIP = socket.gethostbyname(socket.gethostname())
|
||||
wrongIP = "192.168.123.321"
|
||||
cbx.go(CBX)
|
||||
cbx.go("plugins/network")
|
||||
self.assertRaises(TwillAssertionError, cbx.notfind, str("Data.Status.Plugins.network=" + actIP))
|
||||
self.assertRaises(TwillAssertionError, cbx.find, str("Data.Status.Plugins.network= "))
|
||||
self.assertRaises(TwillAssertionError, cbx.find, str("Data.Status.Plugins.network=" + wrongIP))
|
||||
#TODO: change the address and test again
|
||||
#print cbx.show()
|
||||
print cbx.showhistory()
|
||||
print cbx.showforms()
|
||||
print "1"
|
||||
cbx.formvalue('1','ip4',"123")
|
||||
print "a"
|
||||
cbx.submit()
|
||||
print "b"
|
||||
cbx.code(200)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue