Commit 3eeae716 authored by Romain Courteaud's avatar Romain Courteaud Committed by Rafael Monnerat

slapos_erp5: stop using createZODBPythonScript

parent 4998d98c
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime from DateTime import DateTime
from zExceptions import Unauthorized from zExceptions import Unauthorized
class TestSlapOSERP5CleanupActiveProcess(SlapOSTestCaseMixinWithAbort): class TestSlapOSERP5CleanupActiveProcess(SlapOSTestCaseMixinWithAbort):
def _simulateActiveProcess_deleteSelf(self): def check_cleanup_active_process_alarm(self, date, test_method):
script_name = 'ActiveProcess_deleteSelf'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""description = '%s\\nVisited by ActiveProcess_deleteSelf' % context.getDescription()
context.edit(description=description)""")
transaction.commit()
def _dropActiveProcess_deleteSelf(self):
script_name = 'ActiveProcess_deleteSelf'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def check_cleanup_active_process_alarm(self, date, assert_method):
def verify_getCreationDate_call(*args, **kwargs): def verify_getCreationDate_call(*args, **kwargs):
return date return date
ActiveProcessClass = self.portal.portal_types.getPortalTypeClass( ActiveProcessClass = self.portal.portal_types.getPortalTypeClass(
...@@ -44,6 +24,13 @@ context.edit(description=description)""") ...@@ -44,6 +24,13 @@ context.edit(description=description)""")
) )
self.assertEqual(active_process.getCreationDate(), date) self.assertEqual(active_process.getCreationDate(), date)
test_method(
self.portal.portal_alarms.slapos_erp5_cleanup_active_process,
active_process,
'ActiveProcess_deleteSelf',
attribute='description'
)
"""
self.tic() self.tic()
self._simulateActiveProcess_deleteSelf() self._simulateActiveProcess_deleteSelf()
try: try:
...@@ -56,13 +43,13 @@ context.edit(description=description)""") ...@@ -56,13 +43,13 @@ context.edit(description=description)""")
assert_method(active_process.getDescription('').\ assert_method(active_process.getDescription('').\
endswith("Visited by ActiveProcess_deleteSelf"), endswith("Visited by ActiveProcess_deleteSelf"),
active_process.getDescription('')) active_process.getDescription(''))"""
def test_alarm_old_active_process(self): def test_alarm_old_active_process(self):
self.check_cleanup_active_process_alarm(DateTime() - 22, self.assertTrue) self.check_cleanup_active_process_alarm(DateTime() - 22, self._test_alarm)
def test_alarm_new_active_process(self): def test_alarm_new_active_process(self):
self.check_cleanup_active_process_alarm(DateTime() - 20, self.assertFalse) self.check_cleanup_active_process_alarm(DateTime() - 20, self._test_alarm_not_visited)
class TestSlapOSERP5ActiveProcess_deleteSelf(SlapOSTestCaseMixinWithAbort): class TestSlapOSERP5ActiveProcess_deleteSelf(SlapOSTestCaseMixinWithAbort):
......
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSERP5Alarm</string> </value> <value> <string>testSlapOSERP5Alarm</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
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