Commit 7f3e94f8 authored by Gabriel L. Oliveira's avatar Gabriel L. Oliveira

2011-05-17 gabriel.oliveira

* refactor to apply code patterns
parent 5d271ddb
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGDocsSharing(UNGTestMixin):
"""tests related to the action of share documents on UNG Docs"""
def test_share_web_page_with_another_user(self):
"""test that web_page is correctly shared with another user"""
self.selenium.open("ERP5Site_createNewWebDocument?template=web_page_template")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.type("//input[@id=\"name\"]", "Document Shared")
self.selenium.click("//p[@id=\"more_properties\"]")
self.selenium.type("//input[@id=\"version\"]", "002")
self.selenium.type("//input[@id=\"language\"]", "pt-br")
self.selenium.type("//textarea[@id=\"keyword_list\"]", "My Subject")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("002", self.selenium.get_value("//input[@id=\"version\"]"))
self.assertEqual("pt-br", self.selenium.get_value("//input[@id=\"language\"]"))
self.assertEqual("My Subject", self.selenium.get_value("//textarea[@id=\"keyword_list\"]"))
self.assertEqual("Document Shared", self.selenium.get_value("//input[@id=\"name\"]"))
self.selenium.click("//a[@id=\"share_document\"]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Shared", self.selenium.get_text("//a[@name=\"document_state\"]"))
document_url = self.selenium.get_text("//span[@id=\"sharing_url\"]")
self.wait_for_activities()
self.selenium.open("")
self.selenium.wait_for_page_to_load("30000")
#XXX this could be changed (for a generic approach) to //button[@value='ung_domain/shared.0']
self.selenium.click("//table[@class=\"your_listbox-table-domain-tree\"]/tbody/tr[9]/td/button")
self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_text_present("No Result"))
self.assertEqual("Shared by me", self.selenium.get_text("//button[@class=\"tree-open\"]"))
self.selenium.click("//div[@id='wrapper_navigation']/div[2]/fieldset/div[2]/div/div/a[5]")
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.selenium.open(document_url)
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Document Shared", self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("002", self.selenium.get_value("//input[@id=\"version\"]"))
self.assertEqual("pt-br", self.selenium.get_value("//input[@id=\"language\"]"))
self.assertEqual("My Subject", self.selenium.get_value("//textarea[@id=\"keyword_list\"]"))
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.login_as_default_user()
self.selenium.click("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.selenium.type("//input[@id=\"version\"]", "003")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("003", self.selenium.get_value("//input[@id=\"version\"]"))
#XXX this test delete all documents here
# but it won't be done
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
class TestUNGShareDocumentInUNGDocs(BaseUNGTest):
def test_ung_share_document_in_ung_docs(self):
sel = self.selenium
self.init()
self.login_as_default_user()
self.set_default_tree_view()
sel.open("ERP5Site_createNewWebDocument?template=web_page_template")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sel.type("//input[@id=\"name\"]", "Document Shared")
sel.click("//p[@id=\"more_properties\"]")
sel.type("//input[@id=\"version\"]", "002")
sel.type("//input[@id=\"language\"]", "pt-br")
sel.type("//textarea[@id=\"keyword_list\"]", "My Subject")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sel.click("//p[@id=\"more_properties\"]")
self.assertEqual("002", sel.get_value("//input[@id=\"version\"]"))
self.assertEqual("pt-br", sel.get_value("//input[@id=\"language\"]"))
self.assertEqual("My Subject", sel.get_value("//textarea[@id=\"keyword_list\"]"))
self.assertEqual("Document Shared", sel.get_value("//input[@id=\"name\"]"))
sel.click("//a[@id=\"share_document\"]")
sel.wait_for_page_to_load("30000")
self.assertEqual("Shared", sel.get_text("//a[@name=\"document_state\"]"))
document_url = sel.get_text("//span[@id=\"sharing_url\"]")
self.wait_for_activities()
sel.open("")
sel.wait_for_page_to_load("30000")
#XXX this could be changed (for a generic approach) to //button[@value='ung_domain/shared.0']
sel.click("//table[@class=\"your_listbox-table-domain-tree\"]/tbody/tr[9]/td/button")
sel.wait_for_page_to_load("30000")
self.failIf(sel.is_text_present("No Result"))
self.assertEqual("Shared by me", sel.get_text("//button[@class=\"tree-open\"]"))
sel.click("//div[@id='wrapper_navigation']/div[2]/fieldset/div[2]/div/div/a[5]")
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")
sel.open(document_url)
sel.wait_for_page_to_load("30000")
self.assertEqual("Document Shared", sel.get_text("//a[@name=\"document_title\"]"))
sel.click("//a[@name=\"document_title\"]")
sel.click("//p[@id=\"more_properties\"]")
self.assertEqual("002", sel.get_value("//input[@id=\"version\"]"))
self.assertEqual("pt-br", sel.get_value("//input[@id=\"language\"]"))
self.assertEqual("My Subject", sel.get_value("//textarea[@id=\"keyword_list\"]"))
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
self.login_as_default_user()
sel.click("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr/td[3]/a")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sel.click("//p[@id=\"more_properties\"]")
sel.type("//input[@id=\"version\"]", "003")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sel.click("//p[@id=\"more_properties\"]")
self.assertEqual("003", sel.get_value("//input[@id=\"version\"]"))
#XXX this test delete all documents here
# but it won't be done
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