From mboxrd@z Thu Jan 1 00:00:00 1970 From: ldimaggi@sourceware.org Date: 5 Dec 2006 02:12:20 -0000 Subject: [Cluster-devel] conga/luci/test congaDemoTests.py conga_Helpers.py Message-ID: <20061205021220.24139.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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