* [Cluster-devel] conga/luci/test congaDemoTests.py conga_Helpers.py
@ 2006-12-04 15:48 ldimaggi
0 siblings, 0 replies; 2+ messages in thread
From: ldimaggi @ 2006-12-04 15:48 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: ldimaggi at sourceware.org 2006-12-04 15:48:24
Modified files:
luci/test : congaDemoTests.py conga_Helpers.py
Log message:
Moved code to create/delete users and storage systems into conga_Helpers.py - common code that will be used by multiple tests.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/test/congaDemoTests.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/test/conga_Helpers.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
--- conga/luci/test/congaDemoTests.py 2006/12/01 19:57:52 1.1
+++ conga/luci/test/congaDemoTests.py 2006/12/04 15:48:24 1.2
@@ -33,65 +33,6 @@
class congaDemoTests(unittest.TestCase):
- def createUsers(self, sel, theUsers):
- """Common code to create all users in user dictionary"""
- for userName in theUsers.keys():
- print 'Create user: ' + userName
- sel.click("link=Add a User")
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- sel.type("newUserName", userName)
- sel.type("newPassword", theUsers[userName])
- sel.type("newPasswordConfirm", theUsers[userName])
- sel.click("Submit")
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- self.assertEqual('Do you really want to add the user "' + userName + '"?', sel.get_confirmation())
- # Validation - verify that the success message was displayed for each user
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- self.assertTrue (sel.is_text_present('Added new user "' + userName + '" successfully'))
-
- def deleteUsers(self, sel, theUsers):
- """"Common code to delete all users in user dictionary"""
- for userName in theUsers.keys():
- print 'Delete user: ' + userName
- sel.click("link=Delete a User")
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- sel.select("deluserId", "label=" + userName)
- sel.click("Submit")
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- self.assertEqual('Do you really want to remove the user "' + userName + '"?', sel.get_confirmation())
- # Validation - verify that the success message was displayed for each user
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- self.assertTrue (sel.is_text_present('User "' + userName + '" has been deleted'))
-
- def createStorageSystems(self, sel, theSystems):
- """Common code to create storage systems in the input dictionary"""
- for systemName in theSystems.keys():
- print 'Create storage system: ' + systemName
- sel.click("link=Add a System")
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- sel.type("__SYSTEM0:Addr", systemName)
- sel.type("__SYSTEM0:Passwd", theSystems[systemName])
- sel.click("Submit")
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- # Validation - verify that the success message was displayed for each storage system
- self.assertEqual("Do you really want to add the following Storage Systems:\n" + systemName, sel.get_confirmation())
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- self.assertTrue (sel.is_text_present('Added storage system "' + systemName + '" successfully'))
-
- def deleteStorageSystems(self, sel, theSystems):
- """Common code to delete storage systems in the input dictionary"""
- for systemName in theSystems.keys():
- print 'Delete storage system: ' + systemName
- # Need to handle artifacts names - underscores in strings, not periods
- systemNameMod = systemName.replace('.', '_')
- sel.click("name=__SYSTEM:" + systemNameMod)
- sel.click("document.adminform.Submit")
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- # Validation - verify that the success message was displayed for each storage system
- self.assertEqual("Do you really want to remove the following managed systems:\nStorage Systems:\n-" + systemName, sel.get_confirmation())
- sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- self.assertTrue (sel.is_text_present('Removed storage system "' + systemName + '" successfully'))
-
def setUp(self):
"""Establish connection to selenium server, login to luci """
self.verificationErrors = []
@@ -114,29 +55,49 @@
sel = self.selenium
# Create the storage systems
- self.createStorageSystems(sel, CONGA_STORAGE_SYSTEMS)
-
+ for systemName in CONGA_STORAGE_SYSTEMS:
+ createStorageSystem(sel, systemName, CONGA_STORAGE_SYSTEMS[systemName])
+ # Validation - verify that the success message was displayed for each storage system
+ self.assertEqual("Do you really want to add the following Storage Systems:\n" + systemName, sel.get_confirmation())
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ self.assertTrue (sel.is_text_present('Added storage system "' + systemName + '" successfully'))
+
# View the defined storage systems
sel.select_window("null")
sel.click("link=Manage Systems")
sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
# Delete the storage systems
- self.deleteStorageSystems(sel, CONGA_STORAGE_SYSTEMS)
+ for systemName in CONGA_STORAGE_SYSTEMS:
+ deleteStorageSystem(sel, systemName)
+ # Validation - verify that the success message was displayed for each storage system
+ self.assertEqual("Do you really want to remove the following managed systems:\nStorage Systems:\n-" + systemName, sel.get_confirmation())
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ self.assertTrue (sel.is_text_present('Removed storage system "' + systemName + '" successfully'))
def test_congaUsers(self):
"""Test to create and delete conga users"""
sel = self.selenium
# Create the users
- self.createUsers (sel, CONGA_USERS)
+ for userName in CONGA_USERS.keys():
+ createUser (sel, userName, CONGA_USERS[userName])
+ # Validation - verify that the success message was displayed for each user
+ self.assertEqual('Do you really want to add the user "' + userName + '"?', sel.get_confirmation())
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ self.assertTrue (sel.is_text_present('Added new user "' + userName + '" successfully'))
# Return to homebase page
sel.click("link=homebase")
sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
# Delete the users
- self.deleteUsers (sel, CONGA_USERS)
+ for userName in CONGA_USERS.keys():
+ deleteUser (sel, userName)
+ # Validation - verify that the success message was displayed for each user
+ self.assertEqual('Do you really want to remove the user "' + userName + '"?', sel.get_confirmation())
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ self.assertTrue (sel.is_text_present('User "' + userName + '" has been deleted'))
def test_congaCluster(self):
"""Test to create and delete a cluster"""
@@ -195,7 +156,12 @@
self.assertTrue (sel.is_text_present('Removed cluster "testCluster" successfully'))
# Delete the storage systems created when the cluster was created
- self.deleteStorageSystems(sel, CONGA_CLUSTER_SYSTEMS)
+ for systemName in CONGA_CLUSTER_SYSTEMS:
+ deleteStorageSystem(sel, systemName)
+ # Validation - verify that the success message was displayed for each storage system
+ self.assertEqual("Do you really want to remove the following managed systems:\nStorage Systems:\n-" + systemName, sel.get_confirmation())
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ self.assertTrue (sel.is_text_present('Removed storage system "' + systemName + '" successfully'))
def tearDown(self):
"""Logout and stop Selenium session"""
@@ -207,8 +173,8 @@
def suite():
suite = unittest.TestSuite()
- suite.addTest(congaDemoTests('test_congaStorage'))
- suite.addTest(congaDemoTests('test_congaUsers'))
+ #suite.addTest(congaDemoTests('test_congaStorage'))
+ #suite.addTest(congaDemoTests('test_congaUsers'))
suite.addTest(congaDemoTests('test_congaCluster'))
return suite
--- conga/luci/test/conga_Helpers.py 2006/12/01 19:57:52 1.1
+++ conga/luci/test/conga_Helpers.py 2006/12/04 15:48:24 1.2
@@ -57,8 +57,7 @@
# 'tng3-4.lab.msp.redhat.com':'password'}
CONGA_CLUSTER_SYSTEMS = {'tng3-2.lab.msp.redhat.com':'password',
- 'tng3-3.lab.msp.redhat.com':'password',
- 'tng3-4.lab.msp.redhat.com':'password'}
+ 'tng3-3.lab.msp.redhat.com':'password' }
CONGA_USERS = {'user1':'user1_password',
'user2':'user2_password',
@@ -81,3 +80,44 @@
'user8':'tng3-1.lab.msp.redhat.com',
'user9':'tng3-1.lab.msp.redhat.com',
'user10':'tng3-1.lab.msp.redhat.com'}
+
+def createStorageSystem(sel, systemName, systemPassword):
+ """Common code to create storage systems"""
+ print 'Create storage system: ' + systemName
+ sel.click("link=Add a System")
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ sel.type("__SYSTEM0:Addr", systemName)
+ sel.type("__SYSTEM0:Passwd", systemPassword)
+ sel.click("Submit")
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+
+def deleteStorageSystem(sel, systemName):
+ """Common code to delete storage systems"""
+ print 'Delete storage system: ' + systemName
+ # Need to handle artifacts names - underscores in strings, not periods
+ systemNameMod = systemName.replace('.', '_')
+ sel.click("name=__SYSTEM:" + systemNameMod)
+ sel.click("document.adminform.Submit")
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+
+def createUser(sel, userName, userPassword):
+ """Common code to create users"""
+ print 'Create user: ' + userName
+ sel.click("link=Add a User")
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ sel.type("newUserName", userName)
+ sel.type("newPassword", userPassword)
+ sel.type("newPasswordConfirm", userPassword)
+ sel.click("Submit")
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+
+def deleteUser(sel, userName):
+ """Common code to delete users"""
+ print 'Delete user: ' + userName
+ sel.click("link=Delete a User")
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ sel.select("deluserId", "label=" + userName)
+ sel.click("Submit")
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+
+
\ No newline at end of file
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Cluster-devel] conga/luci/test congaDemoTests.py conga_Helpers.py
@ 2006-12-05 2:12 ldimaggi
0 siblings, 0 replies; 2+ messages in thread
From: ldimaggi @ 2006-12-05 2:12 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: ldimaggi at sourceware.org 2006-12-05 02:12:19
Modified files:
luci/test : congaDemoTests.py conga_Helpers.py
Log message:
More refactoring - pulled login/logout routines into conga_Helpers.py to make more code re-usable.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/test/congaDemoTests.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/test/conga_Helpers.py.diff?cvsroot=cluster&r1=1.2&r2=1.3
--- conga/luci/test/congaDemoTests.py 2006/12/04 15:50:02 1.3
+++ conga/luci/test/congaDemoTests.py 2006/12/05 02:12:18 1.4
@@ -36,19 +36,7 @@
def setUp(self):
"""Establish connection to selenium server, login to luci """
self.verificationErrors = []
- self.selenium = selenium("localhost", 4444, "*firefox", CONGA_SERVER)
- self.selenium.start()
-
- # Login to the luci web app
- self.selenium.open(CONGA_SERVER)
-
- # Wait for "Redirecting, please wait to complete" - it seems like this should not be needed,
- # but as of 20061130, it still is
- time.sleep(10)
- self.selenium.type("__ac_name", CONGA_ADMIN_USERNAME)
- self.selenium.type("__ac_password", CONGA_ADMIN_PASSWORD)
- self.selenium.click("submit")
- self.selenium.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ self.selenium = login (CONGA_ADMIN_USERNAME, CONGA_ADMIN_PASSWORD)
def test_congaStorage(self):
"""Test to create and delete storage systems"""
@@ -165,10 +153,7 @@
def tearDown(self):
"""Logout and stop Selenium session"""
- sel = self.selenium
- self.selenium.click("link=Log out")
- self.selenium.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
- self.selenium.stop()
+ logout(self.selenium)
self.assertEqual([], self.verificationErrors)
def suite():
--- conga/luci/test/conga_Helpers.py 2006/12/04 15:48:24 1.2
+++ conga/luci/test/conga_Helpers.py 2006/12/05 02:12:18 1.3
@@ -119,5 +119,27 @@
sel.select("deluserId", "label=" + userName)
sel.click("Submit")
sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
-
+
+def login(userName, password):
+ """Establish connection to selenium server, login to luci """
+ sel = selenium("localhost", 4444, "*firefox", CONGA_SERVER)
+ sel.start()
+
+ # Login to the luci web app
+ sel.open(CONGA_SERVER)
+
+ # Wait for "Redirecting, please wait to complete" - it seems like this should not be needed,
+ # but as of 20061130, it still is
+ time.sleep(10)
+ sel.type("__ac_name", userName)
+ sel.type("__ac_password", password)
+ sel.click("submit")
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ return sel
+
+def logout(sel):
+ """Logout and stop Selenium session"""
+ sel.click("link=Log out")
+ sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ sel.stop()
\ No newline at end of file
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-12-05 2:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-05 2:12 [Cluster-devel] conga/luci/test congaDemoTests.py conga_Helpers.py ldimaggi
-- strict thread matches above, loose matches on Subject: below --
2006-12-04 15:48 ldimaggi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.