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

2011-05-17 gabriel.oliveira

* refactor to apply code patterns
* subdivide tests by points being tested
parent 7f3e94f8
from UNGTestMixin import UNGTestMixin
import unittest
import re
class TestUNGGadgets(UNGTestMixin):
"""tests related to gadgets on UNG"""
def test_add_and_delete_gadget(self):
"""test:
- default gadget message is show when no gadgets are present
- add gadget
- delete gadget
"""
self.failUnless(self.selenium.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.assertEqual("Add gadgets", self.selenium.get_text("//a[@id=\"add-gadgets\"]/span"))
self.failIf(self.selenium.is_text_present("Join ERP5 Network !"))
self.failIf(self.selenium.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.failUnless(self.selenium.is_text_present("Add Gadget"))
self.selenium.click("//input[@id=\"erp5_documentation\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
self.failUnless(self.selenium.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
self.failIf(self.selenium.is_element_present("//div[@id=\"page_wrapper\"]/div[1]/h4"))
self.selenium.click("//a[@class=\"clickable-block block-remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", self.selenium.get_confirmation()))
self.wait_for_activities()
self.selenium.open("")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Add gadgets", self.selenium.get_text("//a[@id=\"add-gadgets\"]/span"))
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Feed Reader", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.selenium.click("//a[@class=\"clickable-block block-remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", self.selenium.get_confirmation()))
self.wait_for_activities()
self.selenium.open("")
self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
def test_add_two_gadgets(self):
"""test that its possible to add more than just 1 gadget"""
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_documentation\"]")
self.selenium.click("//input[@id=\"erp5_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Feed Reader", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
self.selenium.click("//div[@id=\"portal-column-0\"]/div[1]/h3/span/a[@title=\"Remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", self.selenium.get_confirmation()))
self.wait_for_activities()
self.selenium.open("")
self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_element_present("//div[@id=\"portal-column-0\"]/div[2]/h3/span/a[@title=\"Remove\"]"))
self.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
self.selenium.click("//a[@class=\"clickable-block block-remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", self.selenium.get_confirmation()))
self.wait_for_activities()
self.selenium.open("?reset:int=1")
self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
def test_add_gadget_on_different_users(self):
"""test that different users have different gadgets"""
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_documentation\"]")
self.selenium.click("//input[@id=\"erp5_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.wait_for_activities()
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
#XXX user already created
# self.selenium.click("//td[@id=\"new-account-form\"]")
# self.selenium.type("//input[@name=\"firstname\"]", "Another")
# self.selenium.type("//input[@name=\"lastname\"]", "User")
# self.selenium.type("//input[@name=\"email\"]", "example2@example.com")
# self.selenium.type("//input[@name=\"login_name\"]", "ung_user2")
# self.selenium.type("//input[@name=\"password\"]", "1234")
# 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("30000")
self.failUnless(self.selenium.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.failIf(self.selenium.is_text_present("Join ERP5 Network !"))
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_worklists\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.login_as_default_user()
self.assertNotEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.assertEqual("Feed Reader", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.selenium.type("__ac_name", "zope")
self.selenium.type("__ac_password", "zope")
self.selenium.click("//input[@type=\"submit\"]")
self.selenium.wait_for_page_to_load("30000")
self.failUnless(self.selenium.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_worklists\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.selenium.click("//a[@class=\"clickable-block block-remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", self.selenium.get_confirmation()))
self.wait_for_activities()
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.login_as_default_user()
self.assertNotEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.assertEqual("Feed Reader", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
#XXX clean gadgets from all users after test
# maybe using KnowledgePad tool
# url: http://localhost:18080/erp5/portal_skins/erp5_web_ung_theme/WebSection_viewMenuWidget/pt_editForm
# starting at <div class="front_pad">
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
import re
class TestUNGGadgetInUNGDocs(BaseUNGTest):
def test_ung_gadget_in_ung_docs(self):
sel = self.selenium
self.init()
self.login_as_default_user()
self.failUnless(sel.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.assertEqual("Add gadgets", sel.get_text("//a[@id=\"add-gadgets\"]/span"))
self.failIf(sel.is_text_present("Join ERP5 Network !"))
self.failIf(sel.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
sel.click("//a[@id=\"add-gadgets\"]")
self.failUnless(sel.is_text_present("Add Gadget"))
sel.click("//input[@id=\"erp5_documentation\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
self.failUnless(sel.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
self.failIf(sel.is_element_present("//div[@id=\"page_wrapper\"]/div[1]/h4"))
sel.click("//a[@class=\"clickable-block block-remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("")
sel.wait_for_page_to_load("30000")
self.assertEqual("Add gadgets", sel.get_text("//a[@id=\"add-gadgets\"]/span"))
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_rss\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.assertEqual("Feed Reader", sel.get_text("//span[@class=\"gadget_title\"]"))
sel.click("//a[@class=\"clickable-block block-remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("")
sel.wait_for_page_to_load("30000")
self.failIf(sel.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
# Test add two gadgets
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_documentation\"]")
sel.click("//input[@id=\"erp5_rss\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.assertEqual("Feed Reader", sel.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
sel.click("//div[@id=\"portal-column-0\"]/div[1]/h3/span/a[@title=\"Remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("")
sel.wait_for_page_to_load("30000")
self.failIf(sel.is_element_present("//div[@id=\"portal-column-0\"]/div[2]/h3/span/a[@title=\"Remove\"]"))
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
sel.click("//a[@class=\"clickable-block block-remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("?reset:int=1")
sel.wait_for_page_to_load("30000")
self.failIf(sel.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
# Test gadget with different users
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_documentation\"]")
sel.click("//input[@id=\"erp5_rss\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.wait_for_activities()
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
#XXX user already created
# 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_user2")
# sel.type("//input[@name=\"password\"]", "1234")
# 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("30000")
self.failUnless(sel.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.failIf(sel.is_text_present("Join ERP5 Network !"))
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_worklists\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.assertEqual("ERP5 Worklists", sel.get_text("//span[@class=\"gadget_title\"]"))
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
self.login_as_default_user()
self.assertNotEqual("ERP5 Worklists", sel.get_text("//span[@class=\"gadget_title\"]"))
self.assertEqual("Feed Reader", sel.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
sel.type("__ac_name", "zope")
sel.type("__ac_password", "zope")
sel.click("//input[@type=\"submit\"]")
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_worklists\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.assertEqual("ERP5 Worklists", sel.get_text("//span[@class=\"gadget_title\"]"))
sel.click("//a[@class=\"clickable-block block-remove\"]")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
self.login_as_default_user()
self.assertNotEqual("ERP5 Worklists", sel.get_text("//span[@class=\"gadget_title\"]"))
self.assertEqual("Feed Reader", sel.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
#XXX clean gadgets from all users after test
# maybe using KnowledgePad tool
# url: http://localhost:18080/erp5/portal_skins/erp5_web_ung_theme/WebSection_viewMenuWidget/pt_editForm
# starting at <div class="front_pad">
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