Commit 32780996 authored by Gabriel L. Oliveira's avatar Gabriel L. Oliveira

2011-05-17 gabriel.oliveira

* refactor to apply code patterns
parent 97014879
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGSettings(UNGTestMixin):
"""tests related to UNG settings"""
def test_saving_settings_even_on_different_users(self):
"""test that:
- settings are correct displayed
- settings remain saved
- different users have different settings
"""
self.failIf(self.selenium.is_text_present('Text Format'))
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.failUnless(self.selenium.is_text_present("Text Format"))
self.failUnless(self.selenium.is_text_present("FCK Editor"))
self.selenium.check("//input[@value=\'fck_editor\']")
self.selenium.check("//input[@value=\'text/html\']")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'fck_editor\']@checked"))
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text/html\']@checked"))
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.check("//input[@value=\'text_area\']")
self.selenium.check("//input[@value=\'text/plain\']")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text/plain\']@checked"))
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text_area\']@checked"))
self.selenium.click("//span[@class=\'ui-icon ui-icon-closethick\']")
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load(5000)
#don't try to create a new user since
#test's instance already have one with login_name 'ung_user2'
#XXX this is not correct, because it has to be created once a time
# next ones, just login
## self.selenium.click("//td[@id='new-account-form']")
# # self.selenium.type("//input[@name='firstname']", "Another")
# sel#.type("//input[@name='lastname']", "User")
# self.selenium.type(#"//input[@name='email']", "example2@example.com")
# # self.selenium.type("//input[@name='login_name']", "ung_use#r2")
# self.selenium.type("//input[@name='password']", "1#234")
# self.selenium.type("//input[@name='confirm']", "1234")
# self.selenium.click("//input[@value='Create Account']")
# self.selenium.wait_for_page_to_load(30000)
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.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.check("//input[@value=\'fck_editor\']")
self.selenium.check("//input[@value=\'text/html\']")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.check("//input[@value=\'fck_editor\']")
self.selenium.check("//input[@value=\'text/html\']")
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'fck_editor\']@checked"))
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text/html\']@checked"))
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load(5000)
self.selenium.type("__ac_name", "test_user")
self.selenium.type("__ac_password", "test_user")
self.selenium.click("//input[@type='submit']")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text_area\']@checked"))
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text/plain\']@checked"))
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
class TestUNGSettings(BaseUNGTest):
def test_ung_settings(self):
sel = self.selenium
self.login_as_default_user()
#<tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/init" />
#<tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/login" />
self.failIf(sel.is_text_present('Text Format'))
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.failUnless(sel.is_text_present("Text Format"))
self.failUnless(sel.is_text_present("FCK Editor"))
sel.check("//input[@value=\'fck_editor\']")
sel.check("//input[@value=\'text/html\']")
sel.click("//html/body/div[3]/div[11]/div/button[1]")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'fck_editor\']@checked"))
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text/html\']@checked"))
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
sel.check("//input[@value=\'text_area\']")
sel.check("//input[@value=\'text/plain\']")
sel.click("//html/body/div[3]/div[11]/div/button[1]")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text/plain\']@checked"))
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text_area\']@checked"))
sel.click("//span[@class=\'ui-icon ui-icon-closethick\']")
sel.open("WebSite_logout")
sel.wait_for_page_to_load(5000)
#don't try to create a new user since
#test's instance already have one with login_name 'ung_user2'
#XXX this is not correct, because it has to be created once a time
# next ones, just login
## sel.click("//td[@id='new-account-form']")
# # sel.type("//input[@name='firstname']", "Another")
# sel#.type("//input[@name='lastname']", "User")
# sel.type(#"//input[@name='email']", "example2@example.com")
# # sel.type("//input[@name='login_name']", "ung_use#r2")
# sel.type("//input[@name='password']", "1#234")
# sel.type("//input[@name='confirm']", "1234")
# sel.click("//input[@value='Create Account']")
# sel.wait_for_page_to_load(30000)
sel.type("__ac_name", "ung_user2")
sel.type("__ac_password", "1234")
sel.click("//input[@type='submit']")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
sel.check("//input[@value=\'fck_editor\']")
sel.check("//input[@value=\'text/html\']")
sel.click("//html/body/div[3]/div[11]/div/button[1]")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
sel.check("//input[@value=\'fck_editor\']")
sel.check("//input[@value=\'text/html\']")
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
sel.click("//html/body/div[3]/div[11]/div/button[1]")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'fck_editor\']@checked"))
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text/html\']@checked"))
sel.open("WebSite_logout")
sel.wait_for_page_to_load(5000)
sel.type("__ac_name", "test_user")
sel.type("__ac_password", "test_user")
sel.click("//input[@type='submit']")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text_area\']@checked"))
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text/plain\']@checked"))
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