def test_Empty( self ): from Products.CMFTopic.Topic import Topic topic = Topic('top') query = topic.buildQuery() self.assertEqual( len( query ), 0 )
def _makeTopic(self, id, with_criteria=False): from Products.CMFTopic.Topic import Topic topic = Topic(id) if with_criteria: for field, c_type, attrs in _CRITERIA_DATA: topic.addCriterion(field, c_type) criterion = topic.getCriterion(field) criterion.edit(**attrs) return topic
def setUp(self): import Products.CMFCore import Products.Five from Products.Five import zcml import Products.GenericSetup PlacelessSetup.setUp(self) RequestTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.GenericSetup) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_config('configure.zcml', Products.DCWorkflow) factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite factory('site', 'CMFDefault:default', snapshot=False) self.site = self.root.site self.site._setObject('topic', Topic('topic')) self.topic = self.site.topic self.topic.addCriterion('modified', 'Friendly Date Criterion') self.topic.addCriterion('portal_type', 'String Criterion') type_crit = self.topic.getCriterion('portal_type') type_crit.edit(value='Dummy Content') self.criterion = self.topic.getCriterion('modified') self.now = DateTime() for i in self.day_diffs: dummy_id = 'dummy%i' % i self.site._setObject(dummy_id, DummyContent(id=dummy_id, catalog=1)) dummy_ob = getattr(self.site, dummy_id) dummy_ob.modified_date = self.now + i dummy_ob.reindexObject()
def afterSetUp(self): self.site = self.app.site self.site._setObject('topic', Topic('topic')) self.topic = self.site.topic self.topic.addCriterion('modified', 'Friendly Date Criterion') self.topic.addCriterion('portal_type', 'String Criterion') type_crit = self.topic.getCriterion('portal_type') type_crit.edit(value='Dummy Content') self.criterion = self.topic.getCriterion('modified') self.now = DateTime() for i in self.day_diffs: dummy_id = 'dummy%i' % i self.site._setObject(dummy_id, DummyContent(id=dummy_id, catalog=1)) dummy_ob = getattr(self.site, dummy_id) dummy_ob.modified_date = self.now + i dummy_ob.reindexObject()
def setUp(self): RequestTest.setUp(self) self.root.manage_addProduct['CMFDefault'].manage_addCMFSite('site') self.site = self.root.site self.site._setObject('topic', Topic('topic')) self.topic = self.site.topic self.topic.addCriterion('modified', 'Friendly Date Criterion') self.topic.addCriterion('portal_type', 'String Criterion') type_crit = self.topic.getCriterion('portal_type') type_crit.edit(value='Dummy Content') self.criterion = self.topic.getCriterion('modified') self.now = DateTime() for i in self.day_diffs: dummy_id = 'dummy%i' % i self.site._setObject(dummy_id, DummyContent(id=dummy_id, catalog=1)) dummy_ob = getattr(self.site, dummy_id) dummy_ob.modified_date = self.now + i dummy_ob.reindexObject()
def test_Nested( self ): from Products.CMFTopic.Topic import Topic topic = Topic('top') topic.addCriterion( 'foo', 'String Criterion' ) topic.getCriterion( 'foo' ).edit( 'bar' ) topic.addSubtopic( 'qux' ) subtopic = topic.qux subtopic.addCriterion( 'baz', 'String Criterion' ) subtopic.getCriterion( 'baz' ).edit( 'bam' ) query = subtopic.buildQuery() self.assertEqual( len( query ), 2 ) self.assertEqual( query['foo'], 'bar' ) self.assertEqual( query['baz'], 'bam' ) subtopic.acquireCriteria = 0 query = subtopic.buildQuery() self.assertEqual( len( query ), 1 ) self.assertEqual( query['baz'], 'bam' )
def _makeOne(self, id, *args, **kw): from Products.CMFTopic.Topic import Topic return self.site._setObject( id, Topic(id, *args, **kw) )
def __call__(self, id): topic = Topic(id) topic.portal_type = 'Topic' return topic
def _makeOne(self, id, *args, **kw): return self.site._setObject(id, Topic(id, *args, **kw))
def test_Simple( self ): from Products.CMFTopic.Topic import Topic topic = Topic('top') topic.addCriterion( 'foo', 'String Criterion' ) topic.getCriterion( 'foo' ).edit( 'bar' ) query = topic.buildQuery() self.assertEqual( len(query), 1 ) self.assertEqual( query['foo'], 'bar' ) topic.addCriterion( 'baz', 'Integer Criterion' ) topic.getCriterion( 'baz' ).edit( 43 ) query = topic.buildQuery() self.assertEqual( len( query ), 2 ) self.assertEqual( query[ 'foo' ], 'bar' ) self.assertEqual( query[ 'baz' ], 43 )