Commit 5d271ddb authored by Gabriel L. Oliveira's avatar Gabriel L. Oliveira

2011-05-17 gabriel.oliveira

* refactor to apply code patterns
parent ee0ce4f4
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGLogin(UNGTestMixin):
"""tests related to login on UNG"""
def test_login(self):
"""try to login as different users"""
self.selenium.open("WebSite_logout")
self.login_as_default_user()
#XXX bug because All Documents is not selected by default (it's saving "cache")
self.set_default_tree_view()
self.assertEqual("All Documents", self.selenium.get_text("//button[@class='tree-open']"))
self.assertEqual("Settings", self.selenium.get_text("//a[@id='settings']"))
self.failUnless(self.selenium.is_text_present("Web Illustration"))
self.failUnless(self.selenium.is_text_present("Web Page"))
self.failUnless(self.selenium.is_text_present("Web Table"))
#XXX: the user used on test's instance is 'nsi'
self.failUnless(self.selenium.is_text_present("test_user"))
self.selenium.click("link=Sign out")
self.selenium.wait_for_page_to_load(5000)
self.failUnless(self.selenium.is_text_present("Welcome to UNG Web Office"))
self.failUnless(self.selenium.is_text_present("Create an account now"))
self.selenium.click("//td[@id='new-account-form']")
self.selenium.click("//td[@id='back-login']")
#XXX: user is not created and, by orders, can't be created
#<tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/create-user" />
self.selenium.type("__ac_name", "ung_user2")
self.selenium.type("__ac_password", "1234")
self.selenium.click("//input[@type='submit']")
self.selenium.wait_for_page_to_load(5000)
self.assertEqual("ung_user2", self.selenium.get_text("//div[@class=\' navigation-right\']/fieldset/div[2]/div/div/a[2]"))
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
class TestUNGLogin(BaseUNGTest):
def test_ung_login(self):
sel = self.selenium
self.login_as_default_user()
#XXX bug because All Documents is not selected by default (it's saving "cache")
self.set_default_tree_view()
self.assertEqual("All Documents", sel.get_text("//button[@class='tree-open']"))
self.assertEqual("Settings", sel.get_text("//a[@id='settings']"))
self.failUnless(sel.is_text_present("Web Illustration"))
self.failUnless(sel.is_text_present("Web Page"))
self.failUnless(sel.is_text_present("Web Table"))
#XXX: the user used on test's instance is 'nsi'
self.failUnless(sel.is_text_present("test_user"))
sel.click("link=Sign out")
sel.wait_for_page_to_load(5000)
self.failUnless(sel.is_text_present("Welcome to UNG Web Office"))
self.failUnless(sel.is_text_present("Create an account now"))
sel.click("//td[@id='new-account-form']")
sel.click("//td[@id='back-login']")
#XXX: user is not created and, by orders, can't be created
#<tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/create-user" />
# sel.type("__ac_name", "ung_user")
# sel.type("__ac_password", "1234")
# sel.click("//input[@type='submit']")
# sel.wait_for_page_to_load(5000)
# try: self.assertEqual("ung_user", sel.get_text("//div[@class=\' navigation-right\']/fieldset/div[2]/div/div/a[2]"))
# except AssertionError, e: self.verificationErrors.append(str(e))
if __name__ == "__main__":
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment