Commit ea20f67e authored by Rafael Monnerat's avatar Rafael Monnerat

Major refactoring at Zelenium Launch Test implementation

Changes contains:

Code clean up
Performance optimization and code crimes removal
Do not depend erp5_run_my_doc dependency
parent ab1a8420
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
Include a page template contains a into a Zuite\n
"""\n
if test_id is None or test_id == \'\':\n
test_id = \'\'.join(list(filter(lambda a: a not in ["\'",\'_\', \'-\',\'.\',\' \',\'~\', \':\', \'/\', \'?\', \'#\', \'[\', \']\', \'@\', \'!\', \'$\', \'&\', \'(\', \')\', \'*\',\'+\',\';\',\'=\'], title)))\n
\n
if test_id not in context.objectIds():\n
factory = context.manage_addProduct[\'PageTemplates\']\n
factory.manage_addPageTemplate(test_id, title=title, text=text, REQUEST=None)\n
test = getattr(context, test_id, None)\n
else:\n
test = getattr(context, test_id, None)\n
context.Zuite_editZPT(test, text)\n
test.setTitle(text)\n
\n
return test\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>test_id, title, text</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Zuite_addTest</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Create a zuite or return an existing one after remove his contents.\n
"""\n
if zuite_id not in context.objectIds():\n
factory = context.portal_tests.manage_addProduct[\'Zelenium\']\n
factory.manage_addZuite(id=zuite_id)\n
\n
zuite = getattr(context.portal_tests, zuite_id, None)\n
zuite.manage_delObjects(zuite.objectIds())\n
\n
return zuite\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>zuite_id</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Zuite_addZuite</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
Generate a Zuite (if necessary), create/update the test and redirect to the selenium test created/updated\n
url, web_page or web_page_reference must be set for it to work (or the context should be the Web Page in question)\n
"""\n
\n
zuite = context.getPortalObject().portal_tests.Zuite_addZuite(zuite_id)\n
\n
test = zuite.Zuite_addTest(test_id, \n
title, \n
context.Zuite_extractTest(text, title))\n
\n
return zuite.Base_redirect("core/TestRunner.html?auto=true&test=..%2Ftest_suite_html&resultsUrl=..%2FpostResults")\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>text, title, zuite_id, test_id</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Zuite_createAndLaunchSeleniumTest</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Display Selenium Test</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,85 +50,27 @@ ...@@ -50,85 +50,27 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>"""\n
"""\n
Generate a Zuite (if necessary), create/update the test and redirect to the selenium test created/updated\n Generate a Zuite (if necessary), create/update the test and redirect to the selenium test created/updated\n
url, web_page or web_page_reference must be set for it to work (or the context should be the Web Page in question)\n url, web_page or web_page_reference must be set for it to work (or the context should be the Web Page in question)\n
"""\n """\n
\n \n
if context.getPortalType() in [\'Web Page\', \'Test Page\'] :\n validation = context.Zuite_viewZeleniumTestLauncherValidator(editor=None, \n
web_page = context\n request=context.REQUEST, \n
obj_reference = context.getReference()\n validator = False)\n
if not(obj_reference is None or not obj_reference):\n
zuite_id = obj_reference\n
else:\n
if zuite_id is None or not zuite_id:\n
zuite_id = \'tutorial_zuite\'\n
\n
no_reference = web_page_reference is None or not web_page_reference\n
no_url = url is None or not url\n
\n
validation = context.Zuite_viewZeleniumTestLauncherValidator(editor = None, request = context.REQUEST, validator = False)\n
if not validation[\'result\']:\n if not validation[\'result\']:\n
return context.Base_redirect(validation[\'form_id\'], keep_items = dict(portal_status_message=validation[\'portal_status_message\']))\n return context.Base_redirect(validation[\'form_id\'], \n
\n keep_items = dict(portal_status_message=validation[\'portal_status_message\']))\n
if not no_url:\n
text = context.Zuite_urlRead(url)\n
elif not no_reference:\n
web_page = None\n
for page in context.portal_catalog(portal_type=\'Web Page Module\')[0].objectValues() + context.portal_catalog(portal_type=\'Test Page Module\')[0].objectValues() :\n
if page.getReference() == web_page_reference and page.getValidationState() not in [\'archived\',\'deleted\']:\n
web_page = page\n
break\n
if web_page is None or not web_page:\n
raise Exception(\'Web Page with reference <i>\' + web_page_reference + \'</i> not found.\')\n
text = web_page.getTextContent()\n
else:\n
if isinstance(web_page, str):\n
try:\n
web_page = context.restrictedTraverse(web_page)\n
except:\n
raise Exception(web_page + \' not found with restrictedTraverse.\')\n
text = web_page.getTextContent()\n
\n
portal_tests = context.getPortalObject().portal_tests\n
\n
zuite_path = portal_tests.getPath() + \'/\' + zuite_id\n
try:\n
zuite = context.restrictedTraverse(zuite_path)\n
except:\n
factory = portal_tests.manage_addProduct[\'Zelenium\']\n
factory.manage_addZuite(id=zuite_id)\n
zuite = context.restrictedTraverse(zuite_path)\n
\n
title = web_page.getTitle()\n
text = context.Zuite_extractTest(text, title)\n
\n
\n
if test_id is None or test_id == \'\':\n
test_id = \'\'.join(list(filter(lambda a: a not in ["\'",\'_\', \'-\',\'.\',\' \',\'~\', \':\', \'/\', \'?\', \'#\', \'[\', \']\', \'@\', \'!\', \'$\', \'&\', \'(\', \')\', \'*\',\'+\',\';\',\'=\'], title)))\n
\n
zuite.manage_delObjects([x.getId() for x in zuite.objectValues()])\n
\n
test_path = zuite_path + \'/\' + test_id\n
try:\n
test = context.restrictedTraverse(test_path)\n
context.Zuite_editZPT(test, text)\n
except:\n
factory = zuite.manage_addProduct[\'PageTemplates\']\n
factory.manage_addPageTemplate(test_id, title=title, text = text, REQUEST=None)\n
test = context.restrictedTraverse(test_path)\n
\n
\n \n
return zuite.Base_redirect("core/TestRunner.html?auto=true&test=..%2Ftest_suite_html&resultsUrl=..%2FpostResults")\n return context.Zuite_createAndLaunchSeleniumTest(text=context.Zuite_urlRead(url),\n
title="Download From Web", \n
zuite_id=zuite_id,\n
]]></string> </value> test_id=test_id)\n
</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>url = \'\', web_page = None, web_page_reference = \'\', zuite_id = \'tutorial_zuite\', test_id = \'\'</string> </value> <value> <string>url, zuite_id = \'tutorial_zuite\', test_id = \'\'</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
...@@ -72,8 +72,7 @@ image.setContentType(\'image/png\')\n ...@@ -72,8 +72,7 @@ image.setContentType(\'image/png\')\n
data_text = data_uri.read()\n data_text = data_uri.read()\n
data = data_text.decode(\'base64\')\n data = data_text.decode(\'base64\')\n
\n \n
image.edit(data=data, \n image.edit(data=data,\n
#base_data=data,\n
filename=str(image_reference) + \'.png\', \n filename=str(image_reference) + \'.png\', \n
content_type = \'image/png\')\n content_type = \'image/png\')\n
\n \n
......
...@@ -80,7 +80,11 @@ ...@@ -80,7 +80,11 @@
<item> <item>
<key> <string>center</string> </key> <key> <string>center</string> </key>
<value> <value>
<list/> <list>
<string>your_url</string>
<string>your_zuite_id</string>
<string>your_test_id</string>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -92,21 +96,13 @@ ...@@ -92,21 +96,13 @@
<item> <item>
<key> <string>left</string> </key> <key> <string>left</string> </key>
<value> <value>
<list> <list/>
<string>your_description</string>
<string>your_url</string>
<string>your_web_page</string>
<string>your_web_page_reference</string>
</list>
</value> </value>
</item> </item>
<item> <item>
<key> <string>right</string> </key> <key> <string>right</string> </key>
<value> <value>
<list> <list/>
<string>your_zuite_id</string>
<string>your_test_id</string>
</list>
</value> </value>
</item> </item>
</dictionary> </dictionary>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_description</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string>Set one of the three following fields only</string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_description</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<value> <value>
<list> <list>
<string>description</string> <string>description</string>
<string>display_width</string>
<string>title</string> <string>title</string>
</list> </list>
</value> </value>
...@@ -84,6 +85,10 @@ ...@@ -84,6 +85,10 @@
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>Type the url of the page containing the Zelenium Test. (for external webpages only)</string> </value> <value> <string>Type the url of the page containing the Zelenium Test. (for external webpages only)</string> </value>
</item> </item>
<item>
<key> <string>display_width</string> </key>
<value> <int>120</int> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value> <value> <string>my_string_field</string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>description</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>delegated_message_list</string> </key>
<value>
<list>
<string>external_validator_failed</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_web_page</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>Enter the path to the ERP5 Web Page containing your test.</string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ERP5 Web Page Path</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>description</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>delegated_message_list</string> </key>
<value>
<list>
<string>external_validator_failed</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_web_page_reference</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>Enter the reference to the ERP5 Web Page object containing your test.</string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ERP5 Web Page Reference</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>web_page_context = context.getPortalType() in [\'Web Page\', \'Test Page\']\n <value> <string>web_page_context = context.getPortalType() in [\'Test Page\', \'Web Page\']\n
\n \n
if web_page_context:\n if web_page_context:\n
no_web_page = False\n no_web_page = False\n
...@@ -67,13 +67,17 @@ if no_web_page and no_url and no_reference:\n ...@@ -67,13 +67,17 @@ if no_web_page and no_url and no_reference:\n
return 0\n return 0\n
else:\n else:\n
return dict(result = False, form_id = form_id, portal_status_message=context.Base_translateString("External Url (url), ERP5 Web Page Path (web_page) and ERP5 Web Page Reference (web_page_reference): were omitted, one of them must be set."))\n return dict(result = False, form_id = form_id, portal_status_message=context.Base_translateString("External Url (url), ERP5 Web Page Path (web_page) and ERP5 Web Page Reference (web_page_reference): were omitted, one of them must be set."))\n
elif not (no_url or no_web_page) or not (no_reference or no_web_page) or not (no_url or reference_not_set):\n elif not (no_url or no_web_page) or not (no_reference or no_web_page):\n
if validator:\n if validator:\n
return 0\n return 0\n
elif web_page_context:\n elif web_page_context:\n
return dict(result = False, form_id = form_id, portal_status_message=context.Base_translateString("url, web_page and web_page_reference don\'t need to be set in Web Page context."))\n return dict(result=False, \n
form_id=form_id, \n
portal_status_message=context.Base_translateString("url, web_page and web_page_reference don\'t need to be set in Web Page context."))\n
else:\n else:\n
return dict(result = False, form_id = form_id, portal_status_message=context.Base_translateString("You have to choose between External Url (url), ERP5 Web Page Path (web_page) and ERP5 Web Page Reference (web_page_reference). Only ONE of them must be set."))\n return dict(result=False, \n
form_id=form_id, \n
portal_status_message=context.Base_translateString("You have to choose between External Url (url), ERP5 Web Page Path (web_page) and ERP5 Web Page Reference (web_page_reference). Only ONE of them must be set."))\n
\n \n
if validator:\n if validator:\n
return 1\n return 1\n
......
50 51
\ No newline at end of file \ No newline at end of file
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