Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
CMFTopic.tests.test_DateC.FriendlyDateCriterionTests Class Reference
Inheritance diagram for CMFTopic.tests.test_DateC.FriendlyDateCriterionTests:
Inheritance graph
[legend]
Collaboration diagram for CMFTopic.tests.test_DateC.FriendlyDateCriterionTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def test_Empty
def test_ListOfDefaultDates
def test_Clear
def test_Basic
def test_BadInput
def test_StringAsValue
def test_Today
def test_FiveDaysOld
def test_OneMonthAhead

Static Public Attributes

dictionary lessThanFiveDaysOld
dictionary lessThanOneMonthAhead
dictionary today

Private Member Functions

def _getTargetClass

Private Attributes

 _now
 _old_as_of

Detailed Description

Definition at line 37 of file test_DateC.py.


Member Function Documentation

Definition at line 60 of file test_DateC.py.

00060 
00061     def _getTargetClass(self):
00062         from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
00063 
00064         return FriendlyDateCriterion

Definition at line 53 of file test_DateC.py.

00053 
00054     def setUp(self):
00055         self._now = DateTime()
00056         self._old_as_of = _replace_DC__as_of(lambda: self._now)

Definition at line 57 of file test_DateC.py.

00057 
00058     def tearDown(self):
00059         _replace_DC__as_of(self._old_as_of)

Here is the call graph for this function:

Definition at line 99 of file test_DateC.py.

00099 
00100     def test_BadInput( self ):
00101         friendly = self._makeOne('foo', 'foofield')
00102 
00103         # Bogus value
00104         self.assertRaises( ValueError, friendly.edit, 'blah' )
00105 
00106         # Bogus operation
00107         self.assertRaises( ValueError, friendly.edit, 4, 'min:max', 'old' )
00108 
00109         # Bogus daterange
00110         self.assertRaises( ValueError, friendly.edit, 4, 'max', 'new' )

Definition at line 91 of file test_DateC.py.

00091 
00092     def test_Basic( self ):
00093         friendly = self._makeOne('foo', 'foofield')
00094 
00095         friendly.apply( self.lessThanFiveDaysOld )
00096         self.assertEqual( friendly.value, 5 )
00097         self.assertEqual( friendly.operation, 'max' )
00098         self.assertEqual( friendly.daterange, 'old' )

Definition at line 83 of file test_DateC.py.

00083 
00084     def test_Clear( self ):
00085         friendly = self._makeOne('foo', 'foofield')
00086 
00087         friendly.edit( value=None )
00088         self.assertEqual( friendly.value, None )
00089         self.assertEqual( friendly.operation, 'min' )
00090         self.assertEqual( friendly.daterange, 'old' )

Definition at line 65 of file test_DateC.py.

00065 
00066     def test_Empty( self ):
00067         friendly = self._makeOne('foo', 'foofield')
00068 
00069         self.assertEqual( friendly.getId(), 'foo' )
00070         self.assertEqual( friendly.field, 'foofield' )
00071         self.assertEqual( friendly.value, None )
00072         self.assertEqual( friendly.operation, 'min' )
00073         self.assertEqual( friendly.daterange, 'old' )
00074         self.assertEqual( len( friendly.getCriteriaItems() ), 0 )

Definition at line 138 of file test_DateC.py.

00138 
00139     def test_FiveDaysOld( self ):
00140         # This should create a query
00141         friendly = self._makeOne('foo', 'foofield')
00142 
00143         friendly.apply( self.lessThanFiveDaysOld )
00144         self.assertEqual( friendly.daterange, 'old' )
00145 
00146         result = friendly.getCriteriaItems()
00147         self.assertEqual( len(result), 1 )
00148         self.assertEqual( result[0][0], 'foofield' )
00149         expect_earliest, expect_now = result[0][1]['query']
00150         self.assertEqual( expect_earliest.Date(),
00151                           ( DateTime() - 5 ).Date() )
00152         self.assertEqual( result[0][1]['range'], 'min:max' )

Definition at line 75 of file test_DateC.py.

00075 
00076     def test_ListOfDefaultDates( self ):
00077         friendly = self._makeOne('foo', 'foofield')
00078 
00079         d = friendly.defaultDateOptions()
00080         self.assertEqual( d[0][0], 0 )
00081         self.assertEqual( d[1][0], 1 )
00082         self.assertEqual( d[2][0], 2 )

Definition at line 153 of file test_DateC.py.

00153 
00154     def test_OneMonthAhead( self ):
00155         friendly = self._makeOne('foo', 'foofield')
00156 
00157         friendly.apply( self.lessThanOneMonthAhead )
00158         self.assertEqual( friendly.daterange, 'ahead' )
00159 
00160         result = friendly.getCriteriaItems()
00161         expect_now, expect_latest = result[0][1]['query']
00162         self.assertEqual( expect_latest.Date(), ( DateTime() + 31 ).Date() )
00163         self.assertEqual( expect_now.Date(), DateTime().Date() )
00164         self.assertEqual( result[0][1]['range'], 'min:max' )
00165 

Definition at line 111 of file test_DateC.py.

00111 
00112     def test_StringAsValue( self ):
00113         friendly = self._makeOne('foo', 'foofield')
00114 
00115         friendly.edit( '4' )
00116         self.assertEqual( friendly.value, 4 )
00117 
00118         friendly.edit( '-4' )
00119         self.assertEqual( friendly.value, -4 )
00120 
00121         friendly.edit( '' )
00122         self.assertEqual( friendly.value, None )

Definition at line 123 of file test_DateC.py.

00123 
00124     def test_Today( self ):
00125         friendly = self._makeOne('foo', 'foofield')
00126 
00127         friendly.apply( self.today )
00128         self.assertEqual( friendly.daterange, 'ahead' )
00129 
00130         now = DateTime()
00131 
00132         result = friendly.getCriteriaItems()
00133         self.assertEqual( len(result), 1 )
00134         self.assertEqual( result[0][0], 'foofield' )
00135         self.assertEqual( result[0][1]['query'],
00136                           ( now.earliestTime(), now.latestTime() ) )
00137         self.assertEqual( result[0][1]['range'], 'min:max' )


Member Data Documentation

Definition at line 54 of file test_DateC.py.

Definition at line 55 of file test_DateC.py.

Initial value:
{ 'value': 5
                          , 'operation': 'max'
                          , 'daterange': 'old'
                          }

Definition at line 39 of file test_DateC.py.

Initial value:
{ 'value': 31
                            , 'operation': 'max'
                            , 'daterange': 'ahead'
                            }

Definition at line 44 of file test_DateC.py.

Initial value:
{ 'value': 0
            , 'operation': 'within_day'
            , 'daterange': 'ahead'
            }

Definition at line 48 of file test_DateC.py.


The documentation for this class was generated from the following file: