Commit 58b0bcb1 authored by Jean-Paul Smets's avatar Jean-Paul Smets

added a few more tests to MethodAfterMethod

changed calculation of MAX_PROCESSING_TIME


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1291 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5badc64c
...@@ -109,12 +109,13 @@ class SQLDict(RAMDict): ...@@ -109,12 +109,13 @@ class SQLDict(RAMDict):
if hasattr(activity_tool,'SQLDict_readMessage'): if hasattr(activity_tool,'SQLDict_readMessage'):
now_date = DateTime() now_date = DateTime()
# Sticky processing messages should be set back to non processing # Sticky processing messages should be set back to non processing
max_processing_date = now_date + MAX_PROCESSING_TIME max_processing_date = now_date - MAX_PROCESSING_TIME
# Next processing date in case of error # Next processing date in case of error
next_processing_date = now_date + VALIDATION_ERROR_DELAY next_processing_date = now_date + VALIDATION_ERROR_DELAY
priority = random.choice(priority_weight) priority = random.choice(priority_weight)
# Try to find a message at given priority level which is scheduled for now # Try to find a message at given priority level which is scheduled for now
result = activity_tool.SQLDict_readMessage(processing_node=processing_node, priority=priority, to_date=now_date, to_processing_date = max_processing_date) result = activity_tool.SQLDict_readMessage(processing_node=processing_node, priority=priority,
to_date=now_date, to_processing_date = max_processing_date)
if len(result) == 0: if len(result) == 0:
# If empty, take any message which is scheduled for now # If empty, take any message which is scheduled for now
priority = None priority = None
...@@ -136,7 +137,7 @@ class SQLDict(RAMDict): ...@@ -136,7 +137,7 @@ class SQLDict(RAMDict):
validation_state = m.validate(self, activity_tool) validation_state = m.validate(self, activity_tool)
if validation_state is not VALID: if validation_state is not VALID:
if validation_state in (EXCEPTION, INVALID_PATH): if validation_state in (EXCEPTION, INVALID_PATH):
# There is a serious validation error # There is a serious validation error - we must lower priority
if line.priority > MAX_PRIORITY: if line.priority > MAX_PRIORITY:
# This is an error # This is an error
if len(uid_list) > 0: if len(uid_list) > 0:
...@@ -309,6 +310,10 @@ class SQLDict(RAMDict): ...@@ -309,6 +310,10 @@ class SQLDict(RAMDict):
# Required for tests (time shift) # Required for tests (time shift)
def timeShift(self, activity_tool, delay): def timeShift(self, activity_tool, delay):
"""
To simulate timeShift, we simply substract delay from
all dates in SQLDict message table
"""
activity_tool.SQLDict_timeShift(delay = delay * SECONDS_IN_DAY) activity_tool.SQLDict_timeShift(delay = delay * SECONDS_IN_DAY)
registerActivity(SQLDict) registerActivity(SQLDict)
...@@ -448,6 +448,13 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -448,6 +448,13 @@ class TestCMFActivity(ERP5TypeTestCase):
self.assertEquals(len(message_list),1) self.assertEquals(len(message_list),1)
self.assertEquals(organisation.getTitle(), default_title) # Title should not be changed the first time self.assertEquals(organisation.getTitle(), default_title) # Title should not be changed the first time
self.assertEquals(organisation.getDescription(),self.title1) self.assertEquals(organisation.getDescription(),self.title1)
# Test again without waiting
portal.portal_activities.tic()
get_transaction().commit()
message_list = portal.portal_activities.getMessageList()
self.assertEquals(len(message_list),1)
self.assertEquals(organisation.getTitle(), default_title) # Title should not be changed the first time
self.assertEquals(organisation.getDescription(),self.title1)
# Now wait some time and test again (this should be simulated by changing dates in SQL Queue) # Now wait some time and test again (this should be simulated by changing dates in SQL Queue)
from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
portal.portal_activities.timeShift(2 * VALIDATION_ERROR_DELAY) portal.portal_activities.timeShift(2 * VALIDATION_ERROR_DELAY)
......
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