From 58b0bcb1491a16780509833dd06b0623f0535a85 Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Mon, 26 Jul 2004 08:16:17 +0000 Subject: [PATCH] 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 --- product/CMFActivity/Activity/SQLDict.py | 11 ++++++++--- product/CMFActivity/tests/testCMFActivity.py | 7 +++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/product/CMFActivity/Activity/SQLDict.py b/product/CMFActivity/Activity/SQLDict.py index f3f982f4da..3aa8ed89f9 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 6dc9324378..dec9e1cff4 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) -- 2.30.9