Commit fc353968 authored by Julien Muchembled's avatar Julien Muchembled

Add new ERP5Site_checkDataWithScript script to erp5_core.

It is tested in testERP5Base (ERP5).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21497 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 62df6c03
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>from Products.CMFActivity.ActiveResult import ActiveResult\n
active_result = ActiveResult()\n
severity = len(error_list)\n
if severity == 0:\n
summary = "No error"\n
else:\n
summary = "Error"\n
active_result.edit(summary=summary, severity=severity, detail=\'\\n\'.join(error_list))\n
return active_result\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, error_list</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>title</string>
<string>error_list</string>
<string>Products.CMFActivity.ActiveResult</string>
<string>ActiveResult</string>
<string>active_result</string>
<string>len</string>
<string>severity</string>
<string>summary</string>
<string>_getattr_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_makeActiveResult</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
840 841
\ No newline at end of file \ No newline at end of file
...@@ -34,7 +34,7 @@ from DateTime import DateTime ...@@ -34,7 +34,7 @@ from DateTime import DateTime
from Products.ERP5Type.Utils import convertToUpperCase from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import createZODBPythonScript, FileUpload
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
class TestERP5Base(ERP5TypeTestCase): class TestERP5Base(ERP5TypeTestCase):
...@@ -1171,6 +1171,33 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -1171,6 +1171,33 @@ class TestERP5Base(ERP5TypeTestCase):
self.assertNotEquals(None, assignment.getStopDate()) self.assertNotEquals(None, assignment.getStopDate())
self.assertEquals(DateTime().day(), assignment.getStopDate().day()) self.assertEquals(DateTime().day(), assignment.getStopDate().day())
def test_ERP5Site_checkDataWithScript(self):
test = 'test_ERP5Site_checkDataWithScript'
createZODBPythonScript(self.getSkinsTool().custom, test, '',
'return context.getRelativeUrl(),')
organisation = self.getOrganisationModule() \
.newContent(portal_type='Organisation')
organisation.setDefaultAddressCity('Lille')
organisation.setDefaultAddressZipCode('59000')
person = self.getPersonModule().newContent(portal_type='Person')
person.setDefaultEmailText('nobody@example.com')
portal_activities = self.getActivityTool()
active_process = portal_activities.newActiveProcess()
portal_activities.ERP5Site_checkDataWithScript(method_id=test, tag=test,
active_process=active_process.getPath())
self.tic()
relative_url_list = sum((x.detail.split('\n')
for x in active_process.getResultList()), [])
self.assertEquals(len(relative_url_list), len(set(relative_url_list)))
for obj in organisation, person, person.getDefaultEmailValue():
self.assertTrue(obj.getRelativeUrl() in relative_url_list)
for relative_url in relative_url_list:
self.assertTrue('/' in relative_url)
self.assertNotEquals(None, self.portal.unrestrictedTraverse(relative_url))
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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