def test_Basic( self ): friendly = FriendlyDateCriterion( 'foo', 'foofield' ) friendly.apply( self.lessThanFiveDaysOld ) self.assertEqual( friendly.value, 4 ) self.assertEqual( friendly.operation, 'min' ) self.assertEqual( friendly.daterange, 'old' )
def test_Basic(self): friendly = FriendlyDateCriterion('foo', 'foofield') friendly.apply(self.lessThanFiveDaysOld) self.assertEqual(friendly.value, 4) self.assertEqual(friendly.operation, 'min') self.assertEqual(friendly.daterange, 'old')
def test_OneMonthAhead( self ): friendly = FriendlyDateCriterion( 'foo', 'foofield' ) friendly.apply( self.lessThanOneMonthAhead ) self.assertEqual( friendly.daterange, 'ahead' ) result = friendly.getCriteriaItems() self.assertEqual( result[0][1]['query'].Date(), ( DateTime() + 30 ).Date() ) self.assertEqual( result[0][1]['range'], 'max' )
def test_OneMonthAhead(self): friendly = FriendlyDateCriterion('foo', 'foofield') friendly.apply(self.lessThanOneMonthAhead) self.assertEqual(friendly.daterange, 'ahead') result = friendly.getCriteriaItems() self.assertEqual(result[0][1]['query'].Date(), (DateTime() + 30).Date()) self.assertEqual(result[0][1]['range'], 'max')
def test_OneMonthAhead( self ): from Products.CMFTopic.DateCriteria import FriendlyDateCriterion friendly = FriendlyDateCriterion( 'foo', 'foofield' ) friendly.apply( self.lessThanOneMonthAhead ) self.assertEqual( friendly.daterange, 'ahead' ) result = friendly.getCriteriaItems() self.assertEqual( result[0][1].Date(), ( DateTime() + 30 ).Date() ) self.assertEqual( result[1][1], 'range:max' )
def test_OneMonthAhead(self): from Products.CMFTopic.DateCriteria import FriendlyDateCriterion friendly = FriendlyDateCriterion('foo', 'foofield') friendly.apply(self.lessThanOneMonthAhead) self.assertEqual(friendly.daterange, 'ahead') result = friendly.getCriteriaItems() self.assertEqual(result[0][1].Date(), (DateTime() + 30).Date()) self.assertEqual(result[1][1], 'range:max')
def test_FiveDaysOld(self): friendly = FriendlyDateCriterion('foo', 'foofield') friendly.apply(self.lessThanFiveDaysOld) self.assertEqual(friendly.daterange, 'old') result = friendly.getCriteriaItems() self.assertEqual(len(result), 1) self.assertEqual(result[0][0], 'foofield') self.assertEqual(result[0][1]['query'].Date(), (DateTime() - 4).Date()) self.assertEqual(result[0][1]['range'], 'min')
def test_FiveDaysOld( self ): friendly = FriendlyDateCriterion( 'foo', 'foofield' ) friendly.apply( self.lessThanFiveDaysOld ) self.assertEqual( friendly.daterange, 'old' ) result = friendly.getCriteriaItems() self.assertEqual( len(result), 1 ) self.assertEqual( result[0][0], 'foofield' ) self.assertEqual( result[0][1]['query'].Date(), ( DateTime() - 4 ).Date() ) self.assertEqual( result[0][1]['range'], 'min' )
def test_Today( self ): friendly = FriendlyDateCriterion( 'foo', 'foofield' ) friendly.apply( self.today ) self.assertEqual( friendly.daterange, 'ahead' ) now = DateTime() result = friendly.getCriteriaItems() self.assertEqual( len(result), 1 ) self.assertEqual( result[0][0], 'foofield' ) self.assertEqual( result[0][1]['query'], ( now.earliestTime(), now.latestTime() ) ) self.assertEqual( result[0][1]['range'], 'min:max' )
def test_FiveDaysOld( self ): from Products.CMFTopic.DateCriteria import FriendlyDateCriterion friendly = FriendlyDateCriterion( 'foo', 'foofield' ) friendly.apply( self.lessThanFiveDaysOld ) self.assertEqual( friendly.daterange, 'old' ) result = friendly.getCriteriaItems() self.assertEqual( len( result ), 2 ) self.assertEqual( result[0][0], 'foofield' ) self.assertEqual( result[0][1].Date(), ( DateTime() - 4 ).Date() ) self.assertEqual( result[1][0], 'foofield_usage' ) self.assertEqual( result[1][1], 'range:min' )
def test_FiveDaysOld(self): from Products.CMFTopic.DateCriteria import FriendlyDateCriterion friendly = FriendlyDateCriterion('foo', 'foofield') friendly.apply(self.lessThanFiveDaysOld) self.assertEqual(friendly.daterange, 'old') result = friendly.getCriteriaItems() self.assertEqual(len(result), 2) self.assertEqual(result[0][0], 'foofield') self.assertEqual(result[0][1].Date(), (DateTime() - 4).Date()) self.assertEqual(result[1][0], 'foofield_usage') self.assertEqual(result[1][1], 'range:min')
def test_Today(self): friendly = FriendlyDateCriterion('foo', 'foofield') friendly.apply(self.today) self.assertEqual(friendly.daterange, 'ahead') now = DateTime() result = friendly.getCriteriaItems() self.assertEqual(len(result), 1) self.assertEqual(result[0][0], 'foofield') self.assertEqual(result[0][1]['query'], (now.earliestTime(), now.latestTime())) self.assertEqual(result[0][1]['range'], 'min:max')
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_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' )