Commit 5903206c authored by Romain Courteaud's avatar Romain Courteaud

Move cleanup_active_process alarm.

parent 1cf8dce7
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>cleanup_active_process</string> </value> <value> <string>slapos_erp5_cleanup_active_process</string> </value>
</item> </item>
<item> <item>
<key> <string>periodicity_day_frequency</string> </key> <key> <string>periodicity_day_frequency</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>business_template_skin_layer_priority</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>float</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>business_template_skin_layer_priority</string> </key>
<value> <float>60.0</float> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_administration</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,14 +50,19 @@ ...@@ -50,14 +50,19 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>if context.getPortalType() != \'Active Process\':\n <value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
if context.getPortalType() != \'Active Process\':\n
raise TypeError(\'Call me on Active Process\')\n raise TypeError(\'Call me on Active Process\')\n
\n
context.getParentValue().deleteContent(context.getId())\n context.getParentValue().deleteContent(context.getId())\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5Type.tests.backportUnittest import skip
import json
from DateTime import DateTime
from zExceptions import Unauthorized
class TestSlapOSERP5CleanupActiveProcess(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
def _simulateActiveProcess_deleteSelf(self):
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):
return date
ActiveProcessClass = self.portal.portal_types.getPortalTypeClass(
'Active Process')
ActiveProcessClass.getCreationDate_call = ActiveProcessClass.\
getCreationDate
ActiveProcessClass.getCreationDate = verify_getCreationDate_call
new_id = self.generateNewId()
active_process = self.portal.portal_activities.newContent(
portal_type='Active Process',
title="Active Process %s" % new_id,
reference="ACTPROC-%s" % new_id,
description="Active Process %s" % new_id,
)
self.assertEquals(active_process.getCreationDate(), date)
self._simulateActiveProcess_deleteSelf()
try:
self.portal.portal_alarms.slapos_erp5_cleanup_active_process.activeSense()
self.tic()
finally:
self._dropActiveProcess_deleteSelf()
self.portal.portal_types.resetDynamicDocumentsOnceAtTransactionBoundary()
transaction.commit()
assert_method(active_process.getDescription('').\
endswith("Visited by ActiveProcess_deleteSelf"),
active_process.getDescription(''))
def test_alarm_old_active_process(self):
self.check_cleanup_active_process_alarm(DateTime() - 22, self.assertTrue)
def test_alarm_new_active_process(self):
self.check_cleanup_active_process_alarm(DateTime() - 20, self.assertFalse)
class TestSlapOSERP5ActiveProcess_deleteSelf(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
def createActiveProcess(self):
new_id = self.generateNewId()
return self.portal.portal_activities.newContent(
portal_type='Active Process',
title="Active Process %s" % new_id,
reference="ACTPROC-%s" % new_id,
description="Active Process %s" % new_id,
)
def test_disallowedPortalType(self):
document = self.portal.person_module.newContent()
self.assertRaises(
TypeError,
document.ActiveProcess_deleteSelf,
)
def test_REQUEST_disallowed(self):
active_process = self.createActiveProcess()
self.assertRaises(
Unauthorized,
active_process.ActiveProcess_deleteSelf,
REQUEST={})
def test_default_use_case(self):
active_process = self.createActiveProcess()
module = active_process.getParentValue()
id = active_process.getId()
active_process.ActiveProcess_deleteSelf()
self.assertRaises(
KeyError,
module._getOb,
id)
...@@ -109,6 +109,7 @@ class TestSlaposSkinSelection(testSlapOSMixin): ...@@ -109,6 +109,7 @@ class TestSlaposSkinSelection(testSlapOSMixin):
custom custom
vifib_hosting vifib_hosting
slapos_accounting slapos_accounting
slapos_administration
slapos_cache slapos_cache
slapos_cloud slapos_cloud
slapos_cloud_promise slapos_cloud_promise
...@@ -197,6 +198,7 @@ zpt_generic ...@@ -197,6 +198,7 @@ zpt_generic
""" """
custom custom
slapos_accounting slapos_accounting
slapos_administration
slapos_cache slapos_cache
slapos_cloud slapos_cloud
slapos_cloud_promise slapos_cloud_promise
...@@ -281,6 +283,7 @@ zpt_generic ...@@ -281,6 +283,7 @@ zpt_generic
""" """
custom custom
slapos_accounting slapos_accounting
slapos_administration
slapos_cache slapos_cache
slapos_cloud slapos_cloud
slapos_cloud_promise slapos_cloud_promise
...@@ -366,6 +369,7 @@ zpt_generic ...@@ -366,6 +369,7 @@ zpt_generic
""" """
custom custom
slapos_accounting slapos_accounting
slapos_administration
slapos_cache slapos_cache
slapos_cloud slapos_cloud
slapos_cloud_promise slapos_cloud_promise
...@@ -448,6 +452,7 @@ zpt_generic ...@@ -448,6 +452,7 @@ zpt_generic
""" """
custom custom
slapos_accounting slapos_accounting
slapos_administration
slapos_cache slapos_cache
slapos_cloud slapos_cloud
slapos_cloud_promise slapos_cloud_promise
......
115 116
\ No newline at end of file \ No newline at end of file
portal_alarms/slapos_erp5_cleanup_active_process
\ No newline at end of file
slapos_administration
slapos_core slapos_core
\ No newline at end of file
testSlapOSERP5DefaultScenario testSlapOSERP5DefaultScenario
testSlapOSERP5GroupRoleSecurity testSlapOSERP5GroupRoleSecurity
testSlapOSERP5LocalPermissionSlapOSInteractionWorkflow testSlapOSERP5LocalPermissionSlapOSInteractionWorkflow
testSlapOSERP5SkinSelection testSlapOSERP5SkinSelection
\ No newline at end of file testSlapOSERP5Alarm
\ No newline at end of file
889 890
\ No newline at end of file \ No newline at end of file
portal_alarms/cleanup_active_process
portal_alarms/vifib_check_consistency portal_alarms/vifib_check_consistency
portal_alarms/vifib_lock_person portal_alarms/vifib_lock_person
portal_alarms/vifib_lock_software_instance portal_alarms/vifib_lock_software_instance
......
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