diff test/db_test_base.py @ 4876:74b24b14071a

Fix issue2550835 Race condition for testing geek date intervals
author Ralf Schlatterbeck <rsc@runtux.com>
date Fri, 28 Mar 2014 15:14:29 +0100
parents 6998ad77841e
children f6e76a03b502
line wrap: on
line diff
--- a/test/db_test_base.py	Fri Mar 28 10:54:53 2014 +0100
+++ b/test/db_test_base.py	Fri Mar 28 15:14:29 2014 +0100
@@ -1367,16 +1367,25 @@
 
     def testFilteringRangeGeekInterval(self):
         ae, filter, filter_iter = self.filteringSetup()
+        # Note: When querying, create date one minute later than the
+        # timespan later queried to avoid race conditions where the
+        # creation of the deadline is more than a second ago when
+        # queried -- in that case we wouldn't get the expected result.
+        # By extending the interval by a minute we would need a very
+        # slow machine for this test to fail :-)
         for issue in (
-                { 'deadline': date.Date('. -2d')},
-                { 'deadline': date.Date('. -1d')},
-                { 'deadline': date.Date('. -8d')},
+                { 'deadline': date.Date('. -2d') + date.Interval ('00:01')},
+                { 'deadline': date.Date('. -1d') + date.Interval ('00:01')},
+                { 'deadline': date.Date('. -8d') + date.Interval ('00:01')},
                 ):
             self.db.issue.create(**issue)
         for filt in filter, filter_iter:
             ae(filt(None, {'deadline': '-2d;'}), ['5', '6'])
             ae(filt(None, {'deadline': '-1d;'}), ['6'])
             ae(filt(None, {'deadline': '-1w;'}), ['5', '6'])
+            ae(filt(None, {'deadline': '. -2d;'}), ['5', '6'])
+            ae(filt(None, {'deadline': '. -1d;'}), ['6'])
+            ae(filt(None, {'deadline': '. -1w;'}), ['5', '6'])
 
     def testFilteringIntervalSort(self):
         # 1: '1:10'

Roundup Issue Tracker: http://roundup-tracker.org/