[CMF-checkins] CVS: CMF/CMFTopic/tests - test_DateC.py:1.7

Tres Seaver tseaver@zope.com
Tue, 2 Jul 2002 19:12:21 -0400


Update of /cvs-repository/CMF/CMFTopic/tests
In directory cvs.zope.org:/tmp/cvs-serv8233/CMFTopic/tests

Modified Files:
	test_DateC.py 
Log Message:


  - Enabled "within day" queries for FriendlyDateCriteria E.g.,
    field="modified", value="Now", operation="within_day",
    daterange="old" -> content which was modified "today".
    (Tracker # 474).


=== CMF/CMFTopic/tests/test_DateC.py 1.6 => 1.7 ===
                             , 'daterange': 'ahead'
                             }
+    today = { 'value': 0
+            , 'operation': 'within_day'
+            , 'daterange': 'ahead'
+            }
 
     def test_Interface( self ):
         from Products.CMFTopic.interfaces import Criterion
@@ -104,6 +108,24 @@
 
         friendly.edit( '' )
         self.assertEqual( friendly.value, None )
+
+    def test_Today( self ):
+
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        friendly = FriendlyDateCriterion( 'foo', 'foofield' )
+
+        friendly.apply( self.today )
+        self.assertEqual( friendly.daterange, 'ahead' )
+
+        now = DateTime()
+        
+        result = friendly.getCriteriaItems()
+        self.assertEqual( len( result ), 2 )
+        self.assertEqual( result[0][0], 'foofield' )
+        self.assertEqual( result[0][1], ( now.earliestTime()
+                                        , now.latestTime() ) )
+        self.assertEqual( result[1][0], 'foofield_usage' )
+        self.assertEqual( result[1][1], 'range:min:max' )
 
     def test_FiveDaysOld( self ):