Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
ATContentTypes.tests.test_criteria.TestATDateCriteria Class Reference
Inheritance diagram for ATContentTypes.tests.test_criteria.TestATDateCriteria:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.tests.test_criteria.TestATDateCriteria:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_LessThanPast
def test_LessThanFuture
def test_MoreThanPast
def test_MoreThanFuture
def test_MoreThanNow
def test_MoreThanNow
def afterSetUp
def createDummy
def test_000testsetup
def test_multipleCreateVariants
def test_typeInfo
def test_implements
def test_Z3implements

Public Attributes

 dummy

Static Public Attributes

 klass = ATDateCriteria
string title = 'Friendly Date Criteria'
string meta_type = 'ATFriendlyDateCriteria'
string portal_type = 'ATDateCriteria'

Detailed Description

Definition at line 147 of file test_criteria.py.


Member Function Documentation

Reimplemented in ATContentTypes.tests.test_criteria.TestATRelativePathCriterion, and ATContentTypes.tests.test_criteria.TestATCurrentAuthorCriterion.

Definition at line 68 of file test_criteria.py.

00068 
00069     def afterSetUp(self):
00070         atcttestcase.ATCTSiteTestCase.afterSetUp(self)
00071         self.dummy = self.createDummy(self.klass)

def ATContentTypes.tests.test_criteria.CriteriaTest.createDummy (   self,
  klass,
  id = 'dummy' 
) [inherited]

Definition at line 72 of file test_criteria.py.

00072 
00073     def createDummy(self, klass, id='dummy'):
00074         folder = self.folder
00075         if klass is not None:
00076             dummy = klass(id, 'dummyfield')
00077             # put dummy in context of portal
00078             folder._setObject(id, dummy)
00079             dummy = getattr(folder, id)
00080             dummy.initializeArchetype()
00081         else:
00082             dummy = None
00083         return dummy

Here is the call graph for this function:

Definition at line 84 of file test_criteria.py.

00084 
00085     def test_000testsetup(self):
00086         if self.klass is not None:
00087             self.failUnless(self.klass)
00088             self.failUnless(self.portal_type)
00089             self.failUnless(self.title)
00090             self.failUnless(self.meta_type)
        

Definition at line 119 of file test_criteria.py.

00119 
00120     def test_implements(self):
00121         if self.dummy is not None:
00122             self.failIf(IReferenceable.isImplementedBy(self.dummy))
00123             self.failIf(IExtensibleMetadata.isImplementedBy(self.dummy))
00124             self.failIf(self.dummy.isReferenceable)
00125             self.failUnless(IBaseContent.isImplementedBy(self.dummy))
00126             self.failUnless(IATTopicCriterion.isImplementedBy(self.dummy))
00127             self.failUnless(verifyObject(IBaseContent, self.dummy))
00128             self.failUnless(verifyObject(IATTopicCriterion, self.dummy))

Definition at line 173 of file test_criteria.py.

00173 
00174     def test_LessThanFuture(self):
00175         # A query of the form 'Less than 14 days in the future' should generate
00176         # a min:max query with an end 14 days in the future and a start in the
00177         # present
00178         self.dummy.Schema()['field'].set(self.dummy,'created')
00179         self.dummy.setOperation('less')
00180         self.dummy.setDateRange('+')
00181         self.dummy.setValue('14')
00182         expected_end = (DateTime() + 14).latestTime()
00183         items = self.dummy.getCriteriaItems()
00184         self.assertEquals(len(items),1)
00185         query = items[0][1]
00186         #Range should end on future date at the end of the day
00187         self.assertEquals(query['query'][1], expected_end)
00188         #Range should start today
00189         self.assertEquals(query['query'][0].earliestTime(),
00190                                                     DateTime().earliestTime())
00191         self.assertEquals(query['range'], 'min:max')

Definition at line 153 of file test_criteria.py.

00153 
00154     def test_LessThanPast(self):
00155         # A query of the form 'Less than 14 days ago' should generate a min:max
00156         # query with a start 14 days in the past and an end in the present
00157         self.dummy.Schema()['field'].set(self.dummy,'created')
00158         self.dummy.setOperation('less')
00159         self.dummy.setDateRange('-')
00160         self.dummy.setValue('14')
00161         expected_begin = (DateTime() - 14).earliestTime()
00162         items = self.dummy.getCriteriaItems()
00163         self.assertEquals(len(items),1)
00164         query = items[0][1]
00165         field = items[0][0]
00166         self.assertEquals(field, 'created')
00167         #range should start in past at the beginning of the day
00168         self.assertEquals(query['query'][0], expected_begin)
00169         # range should end today
00170         self.assertEquals(query['query'][1].earliestTime(),
00171                                                     DateTime().earliestTime())
00172         self.assertEquals(query['range'], 'min:max')

Definition at line 206 of file test_criteria.py.

00206 
00207     def test_MoreThanFuture(self):
00208         # A query of the form 'More than 14 days in the future' should generate
00209         # a min query with the value set to a date 14 days in the future.
00210         self.dummy.Schema()['field'].set(self.dummy,'created')
00211         self.dummy.setOperation('more')
00212         self.dummy.setDateRange('+')
00213         self.dummy.setValue('14')
00214         expected_begin = (DateTime() + 14).earliestTime()
00215         items = self.dummy.getCriteriaItems()
00216         self.assertEquals(len(items),1)
00217         query = items[0][1]
00218         self.assertEquals(query['query'], expected_begin)
00219         self.assertEquals(query['range'], 'min')

Definition at line 220 of file test_criteria.py.

00220 
00221     def test_MoreThanNow(self):
00222         # A query of the form 'More than Now' should generate
00223         # a min query with the value set to the present, regardless of the
00224         # past future setting.
00225         self.dummy.Schema()['field'].set(self.dummy,'created')
00226         self.dummy.setOperation('more')
00227         self.dummy.setDateRange('+')
00228         self.dummy.setValue('0')
00229         expected_begin = DateTime().earliestTime()
00230         items = self.dummy.getCriteriaItems()
00231         self.assertEquals(len(items),1)
00232         query = items[0][1]
00233         self.assertEquals(query['query'].earliestTime(), expected_begin)
00234         self.assertEquals(query['range'], 'min')
00235         # Change past/future setting
00236         self.dummy.setDateRange('-')
00237         self.assertEquals(query['query'].earliestTime(), expected_begin)
00238         self.assertEquals(query['range'], 'min')

Here is the caller graph for this function:

Definition at line 239 of file test_criteria.py.

00239 
00240     def test_MoreThanNow(self):
00241         # A query of the form 'Less than Now' should generate
00242         # a max query with the value set to the present, regardless of the
00243         # past future setting.
00244         self.dummy.Schema()['field'].set(self.dummy,'created')
00245         self.dummy.setOperation('less')
00246         self.dummy.setDateRange('+')
00247         self.dummy.setValue('0')
00248         expected_begin = DateTime().earliestTime()
00249         items = self.dummy.getCriteriaItems()
00250         self.assertEquals(len(items),1)
00251         query = items[0][1]
00252         self.assertEquals(query['query'].earliestTime(), expected_begin)
00253         self.assertEquals(query['range'], 'max')
00254         # Change past/future setting
00255         self.dummy.setDateRange('-')
00256         self.assertEquals(query['query'].earliestTime(), expected_begin)
00257         self.assertEquals(query['range'], 'max')
00258 
00259 tests.append(TestATDateCriteria)
00260 

Here is the call graph for this function:

Definition at line 192 of file test_criteria.py.

00192 
00193     def test_MoreThanPast(self):
00194         # A query of the form 'More than 14 days ago' should generate a max
00195         # query with the value set to a date 14 days in the past.
00196         self.dummy.Schema()['field'].set(self.dummy,'created')
00197         self.dummy.setOperation('more')
00198         self.dummy.setDateRange('-')
00199         self.dummy.setValue('14')
00200         expected_begin = (DateTime() - 14).earliestTime()
00201         items = self.dummy.getCriteriaItems()
00202         self.assertEquals(len(items),1)
00203         query = items[0][1]
00204         self.assertEquals(query['query'], expected_begin)
00205         self.assertEquals(query['range'], 'max')

Definition at line 91 of file test_criteria.py.

00091 
00092     def test_multipleCreateVariants(self):
00093         klass = self.klass
00094         id = 'dummy'
00095         field = 'dummyfield'
00096         if klass is not None:
00097             dummy = klass(id, field)
00098             self.failUnless(dummy.getId(), id)
00099             self.failUnless(dummy.Field(), field)
00100 
00101             dummy = klass(id=id, field=field)
00102             self.failUnless(dummy.getId(), id)
00103             self.failUnless(dummy.Field(), field)
00104 
00105             dummy = klass(field, oid=id)
00106             self.failUnless(dummy.getId(), id)
00107             self.failUnless(dummy.Field(), field)
00108 
00109             dummy = klass(field=field, oid=id)
00110             self.failUnless(dummy.getId(), id)
00111             self.failUnless(dummy.Field(), field)

Reimplemented in ATContentTypes.tests.test_criteria.TestATBaseCriterion.

Definition at line 112 of file test_criteria.py.

00112 
00113     def test_typeInfo(self):
00114         if self.dummy is not None:
00115             ti = self.dummy.getTypeInfo()
00116             self.failUnlessEqual(ti.getId(), self.portal_type)
00117             self.failUnlessEqual(ti.Title(), self.title)
00118             self.failUnlessEqual(ti.Metatype(), self.meta_type)
        

Definition at line 129 of file test_criteria.py.

00129 
00130     def test_Z3implements(self):
00131         if self.dummy is not None:
00132             iface = Z3IATTopicCriterion
00133             self.failUnless(Z3verifyObject(iface, self.dummy))


Member Data Documentation

Definition at line 70 of file test_criteria.py.

Reimplemented from ATContentTypes.tests.test_criteria.CriteriaTest.

Definition at line 148 of file test_criteria.py.

string ATContentTypes.tests.test_criteria.TestATDateCriteria.meta_type = 'ATFriendlyDateCriteria' [static]

Reimplemented from ATContentTypes.tests.test_criteria.CriteriaTest.

Definition at line 150 of file test_criteria.py.

Reimplemented from ATContentTypes.tests.test_criteria.CriteriaTest.

Definition at line 151 of file test_criteria.py.

string ATContentTypes.tests.test_criteria.TestATDateCriteria.title = 'Friendly Date Criteria' [static]

Reimplemented from ATContentTypes.tests.test_criteria.CriteriaTest.

Definition at line 149 of file test_criteria.py.


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