[CMF-checkins] SVN: CMF/branches/2.0/C Forward port fix for
time-sensitive criteria search from 1.5 branch.
Tres Seaver
tseaver at palladion.com
Fri Jun 15 15:46:31 EDT 2007
Log message for revision 76717:
Forward port fix for time-sensitive criteria search from 1.5 branch.
Changed:
U CMF/branches/2.0/CHANGES.txt
U CMF/branches/2.0/CMFTopic/DateCriteria.py
U CMF/branches/2.0/CMFTopic/tests/test_DateC.py
U CMF/branches/2.0/CMFTopic/version.txt
-=-
Modified: CMF/branches/2.0/CHANGES.txt
===================================================================
--- CMF/branches/2.0/CHANGES.txt 2007-06-15 17:32:28 UTC (rev 76716)
+++ CMF/branches/2.0/CHANGES.txt 2007-06-15 19:46:30 UTC (rev 76717)
@@ -2,6 +2,9 @@
Bug Fixes
+ - Backported test fix from 2.1 branch which suppresses race conditions
+ in date-based topic criteria tests.
+
- CMFCore.CMFBTreeFolder: CMFBTreeFolders could not be used as the
toplevel /Members container.
(http://www.zope.org/Collectors/CMF/441)
@@ -9,7 +12,7 @@
- Fixed DST-driven test breakage in CMFCalendar by adding an optional
'zone' argument to the DublineCore methods which return string
rednitions of date metadata.
- (http://www.zope.org/Collectors/CMF/476)
+ (http://www.zope.org/Collectors/CMF/476)
- Fixed test failures due to changes in TALES expression parsing under
Zope 2.10.
Modified: CMF/branches/2.0/CMFTopic/DateCriteria.py
===================================================================
--- CMF/branches/2.0/CMFTopic/DateCriteria.py 2007-06-15 17:32:28 UTC (rev 76716)
+++ CMF/branches/2.0/CMFTopic/DateCriteria.py 2007-06-15 19:46:30 UTC (rev 76717)
@@ -27,6 +27,7 @@
from permissions import View
from Topic import Topic
+_as_of = DateTime # Allow for controlled value when testing
class FriendlyDateCriterion( AbstractCriterion ):
@@ -131,7 +132,8 @@
elif operation == 'min':
operation = 'max'
- date = DateTime() + value
+ now = _as_of()
+ date = now + value
if operation == 'within_day':
# When items within a day are requested, the range is between
@@ -142,7 +144,7 @@
elif operation == 'min':
if value != 0:
if self.daterange == 'old':
- date_range = (date, DateTime())
+ date_range = (date, now)
return ( ( field, { 'query': date_range
, 'range': 'min:max'
} ), )
@@ -159,7 +161,7 @@
if self.daterange == 'old':
return ((field, {'query': date, 'range': operation}),)
else:
- date_range = (DateTime(), date.latestTime())
+ date_range = (now, date.latestTime())
return ( ( field, { 'query': date_range
, 'range': 'min:max'
} ), )
Modified: CMF/branches/2.0/CMFTopic/tests/test_DateC.py
===================================================================
--- CMF/branches/2.0/CMFTopic/tests/test_DateC.py 2007-06-15 17:32:28 UTC (rev 76716)
+++ CMF/branches/2.0/CMFTopic/tests/test_DateC.py 2007-06-15 19:46:30 UTC (rev 76717)
@@ -28,7 +28,13 @@
from common import CriterionTestCase
+def _replace_DC__as_of(new_callable):
+ from Products.CMFTopic import DateCriteria
+ old_value = DateCriteria._as_of
+ DateCriteria._as_of = new_callable
+ return old_value
+
class FriendlyDateCriterionTests(CriterionTestCase):
lessThanFiveDaysOld = { 'value': 5
@@ -45,6 +51,13 @@
, 'daterange': 'ahead'
}
+ def setUp(self):
+ self._now = DateTime()
+ self._old_as_of = _replace_DC__as_of(lambda: self._now)
+
+ def tearDown(self):
+ _replace_DC__as_of(self._old_as_of)
+
def _getTargetClass(self):
from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
@@ -180,6 +193,7 @@
type_crit.edit(value='Dummy Content')
self.criterion = self.topic.getCriterion('modified')
self.now = DateTime()
+ self._old_as_of = _replace_DC__as_of(lambda: self.now)
for i in self.day_diffs:
dummy_id = 'dummy%i' % i
@@ -194,6 +208,9 @@
RequestTest.tearDown(self)
cleanUp()
+ def beforeTearDown(self):
+ _replace_DC__as_of(self._old_as_of)
+
def test_Harness(self):
# Make sure the test harness is set up OK
ob_values = self.site.objectValues(['Dummy'])
Modified: CMF/branches/2.0/CMFTopic/version.txt
===================================================================
--- CMF/branches/2.0/CMFTopic/version.txt 2007-06-15 17:32:28 UTC (rev 76716)
+++ CMF/branches/2.0/CMFTopic/version.txt 2007-06-15 19:46:30 UTC (rev 76717)
@@ -1 +1 @@
-CMF-2.0.0
+CMF-2.0.0+
More information about the CMF-checkins
mailing list