[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci/test congaDemoTests.py conga_Helpers.py



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	ldimaggi 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]