Skip to contentSkip to conversation

conga/luci/test congaDemoTests.py conga_Helpers.py

Cluster-devel [email protected] 1 participant 1 message Dec 4, 2006

lore
Share & tools
lore
#0 lore raw

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

luci/test/congaDemoTests.py +33 -67
@@ -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
 
luci/test/conga_Helpers.py +42 -2

54 lines not on this page · raw message