diff --git a/product/CMFActivity/Activity/SQLDict.py b/product/CMFActivity/Activity/SQLDict.py index f3f982f4da7240f555e13ab9c6276bb21a35da81..3aa8ed89f923e05de3429f2e56e7e70eb7cb7abf 100755 --- a/product/CMFActivity/Activity/SQLDict.py +++ b/product/CMFActivity/Activity/SQLDict.py @@ -109,12 +109,13 @@ class SQLDict(RAMDict): if hasattr(activity_tool,'SQLDict_readMessage'): now_date = DateTime() # 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 = now_date + VALIDATION_ERROR_DELAY priority = random.choice(priority_weight) # 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 empty, take any message which is scheduled for now priority = None @@ -136,7 +137,7 @@ class SQLDict(RAMDict): validation_state = m.validate(self, activity_tool) if validation_state is not VALID: 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: # This is an error if len(uid_list) > 0: @@ -309,6 +310,10 @@ class SQLDict(RAMDict): # Required for tests (time shift) 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) registerActivity(SQLDict) diff --git a/product/CMFActivity/tests/testCMFActivity.py b/product/CMFActivity/tests/testCMFActivity.py index 6dc932437846bcb42daccdcc88a226f4eeaf327b..dec9e1cff4659c6758e80682847281e9e21658bc 100755 --- a/product/CMFActivity/tests/testCMFActivity.py +++ b/product/CMFActivity/tests/testCMFActivity.py @@ -448,6 +448,13 @@ class TestCMFActivity(ERP5TypeTestCase): 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) + # 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) from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY portal.portal_activities.timeShift(2 * VALIDATION_ERROR_DELAY)