Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFCore.tests.test_PortalFolder.ContentFilterTests Class Reference

List of all members.

Public Member Functions

def setUp
def test_empty
def test_Type
def test_portal_type
def test_Title
def test_Creator
def test_Description
def test_Subject
def test_Subject2
def test_created
def test_created2
def test_modified
def test_modified2
def test_mixed

Public Attributes

 dummy

Detailed Description

Definition at line 544 of file test_PortalFolder.py.


Member Function Documentation

Definition at line 546 of file test_PortalFolder.py.

00546 
00547     def setUp( self ):
00548         self.dummy=DummyContent('Dummy')

Definition at line 698 of file test_PortalFolder.py.

00698 
00699     def test_created( self ):
00700 
00701         from Products.CMFCore.PortalFolder import ContentFilter
00702 
00703         cfilter = ContentFilter( created=DateTime( '2001/01/01' )
00704                                , created_usage='range:min' )
00705         dummy = self.dummy
00706         assert not cfilter( dummy )
00707         dummy.created_date = DateTime( '2000/12/31' )
00708         assert not cfilter( dummy )
00709         dummy.created_date = DateTime( '2001/12/31' )
00710         assert cfilter( dummy )
00711         dummy.created_date = DateTime( '2001/01/01' )
00712         assert cfilter( dummy )
00713         desc = str( cfilter )
00714         lines = desc.split('; ')
00715         assert len( lines ) == 1
00716         assert lines[0] == 'Created since: 2001/01/01'

Definition at line 717 of file test_PortalFolder.py.

00717 
00718     def test_created2( self ):
00719 
00720         from Products.CMFCore.PortalFolder import ContentFilter
00721 
00722         cfilter = ContentFilter( created=DateTime( '2001/01/01' )
00723                                , created_usage='range:max' )
00724 
00725         dummy = self.dummy
00726         assert not cfilter( dummy )
00727         dummy.created_date = DateTime( '2000/12/31' )
00728         assert cfilter( dummy )
00729         dummy.created_date = DateTime( '2001/12/31' )
00730         assert not cfilter( dummy )
00731         dummy.created_date = DateTime( '2001/01/01' )
00732         assert cfilter( dummy )
00733         desc = str( cfilter )
00734         lines = desc.split('; ')
00735         assert len( lines ) == 1
00736         assert lines[0] == 'Created before: 2001/01/01'

Definition at line 623 of file test_PortalFolder.py.

00623 
00624     def test_Creator( self ):
00625 
00626         from Products.CMFCore.PortalFolder import ContentFilter
00627 
00628         cfilter = ContentFilter( Creator='moe' )
00629         dummy = self.dummy
00630         self.failIf( cfilter(dummy) )
00631         dummy.creators = ('curly',)
00632         self.failIf( cfilter(dummy) )
00633         dummy.creators = ('moe',)
00634         self.failUnless( cfilter(dummy) )
00635         dummy.creators = ('moe', 'curly')
00636         self.failUnless( cfilter(dummy) )
00637         desc = str( cfilter )
00638         lines = desc.split('; ')
00639         self.assertEqual(len( lines ),1)
00640         self.assertEqual(lines[0],'Creator: moe')

Definition at line 641 of file test_PortalFolder.py.

00641 
00642     def test_Description( self ):
00643 
00644         from Products.CMFCore.PortalFolder import ContentFilter
00645 
00646         cfilter = ContentFilter( Description='funny' )
00647         dummy = self.dummy
00648         assert not cfilter( dummy )
00649         dummy.description = 'sad'
00650         assert not cfilter( dummy )
00651         dummy.description = 'funny'
00652         assert cfilter( dummy )
00653         dummy.description = 'it is funny you should mention it...'
00654         assert cfilter( dummy )
00655         desc = str( cfilter )
00656         lines = desc.split('; ')
00657         assert len( lines ) == 1
00658         assert lines[0] == 'Description: funny'

Definition at line 549 of file test_PortalFolder.py.

00549 
00550     def test_empty( self ):
00551 
00552         from Products.CMFCore.PortalFolder import ContentFilter
00553 
00554         cfilter = ContentFilter()
00555         dummy = self.dummy
00556         assert cfilter( dummy )
00557         desc = str( cfilter )
00558         lines = filter( None, desc.split('; ') )
00559         assert not lines

Definition at line 775 of file test_PortalFolder.py.

00775 
00776     def test_mixed( self ):
00777 
00778         from Products.CMFCore.PortalFolder import ContentFilter
00779 
00780         cfilter = ContentFilter( created=DateTime( '2001/01/01' )
00781                                , created_usage='range:max'
00782                                , Title='foo'
00783                                )
00784 
00785         dummy = self.dummy
00786         assert not cfilter( dummy )
00787         dummy.created_date = DateTime( '2000/12/31' )
00788         assert not cfilter( dummy )
00789         dummy.created_date = DateTime( '2001/12/31' )
00790         assert not cfilter( dummy )
00791         dummy.created_date = DateTime( '2001/01/01' )
00792         assert not cfilter( dummy )
00793 
00794         dummy.title = 'ohsofoolish'
00795         del dummy.created_date
00796         assert not cfilter( dummy )
00797         dummy.created_date = DateTime( '2000/12/31' )
00798         assert cfilter( dummy )
00799         dummy.created_date = DateTime( '2001/12/31' )
00800         assert not cfilter( dummy )
00801         dummy.created_date = DateTime( '2001/01/01' )
00802         assert cfilter( dummy )
00803 
00804         desc = str( cfilter )
00805         lines = desc.split('; ')
00806         assert len( lines ) == 2, lines
00807         assert 'Created before: 2001/01/01' in lines
00808         assert 'Title: foo' in lines
00809 
00810 
00811 #------------------------------------------------------------------------------
00812 #   Tests for security-related CopySupport lifted from the Zope 2.7
00813 #   / head OFS.tests.testCopySupport (see Collector #259).
#------------------------------------------------------------------------------

Definition at line 737 of file test_PortalFolder.py.

00737 
00738     def test_modified( self ):
00739 
00740         from Products.CMFCore.PortalFolder import ContentFilter
00741 
00742         cfilter = ContentFilter( modified=DateTime( '2001/01/01' )
00743                                , modified_usage='range:min' )
00744         dummy = self.dummy
00745         assert not cfilter( dummy )
00746         dummy.modified_date = DateTime( '2000/12/31' )
00747         assert not cfilter( dummy )
00748         dummy.modified_date = DateTime( '2001/12/31' )
00749         assert cfilter( dummy )
00750         dummy.modified_date = DateTime( '2001/01/01' )
00751         assert cfilter( dummy )
00752         desc = str( cfilter )
00753         lines = desc.split('; ')
00754         assert len( lines ) == 1
00755         assert lines[0] == 'Modified since: 2001/01/01'

Definition at line 756 of file test_PortalFolder.py.

00756 
00757     def test_modified2( self ):
00758 
00759         from Products.CMFCore.PortalFolder import ContentFilter
00760 
00761         cfilter = ContentFilter( modified=DateTime( '2001/01/01' )
00762                                , modified_usage='range:max' )
00763         dummy = self.dummy
00764         assert not cfilter( dummy )
00765         dummy.modified_date = DateTime( '2000/12/31' )
00766         assert cfilter( dummy )
00767         dummy.modified_date = DateTime( '2001/12/31' )
00768         assert not cfilter( dummy )
00769         dummy.modified_date = DateTime( '2001/01/01' )
00770         assert cfilter( dummy )
00771         desc = str( cfilter )
00772         lines = desc.split('; ')
00773         assert len( lines ) == 1
00774         assert lines[0] == 'Modified before: 2001/01/01'

Definition at line 585 of file test_PortalFolder.py.

00585 
00586     def test_portal_type( self ):
00587 
00588         from Products.CMFCore.PortalFolder import ContentFilter
00589 
00590         cfilter = ContentFilter( portal_type='some_pt' )
00591         dummy = self.dummy
00592         assert not cfilter( dummy )
00593         dummy.portal_type = 'asdf'
00594         assert not cfilter( dummy )
00595         dummy.portal_type = 'some_ptyyy'
00596         assert not cfilter( dummy )
00597         dummy.portal_type = 'xxxsome_ptyyy'
00598         assert not cfilter( dummy )
00599         dummy.portal_type = 'some_pt'
00600         assert cfilter( dummy )
00601         desc = str( cfilter )
00602         lines = desc.split('; ')
00603         assert len( lines ) == 1
00604         assert lines[0] == 'Portal Type: some_pt'

Definition at line 659 of file test_PortalFolder.py.

00659 
00660     def test_Subject( self ):
00661 
00662         from Products.CMFCore.PortalFolder import ContentFilter
00663 
00664         cfilter = ContentFilter( Subject=('foo',) )
00665         dummy = self.dummy
00666         assert not cfilter( dummy )
00667         dummy.subject = ( 'bar', )
00668         assert not cfilter( dummy )
00669         dummy.subject = ( 'foo', )
00670         assert cfilter( dummy )
00671         dummy.subject = ( 'foo', 'bar', )
00672         assert cfilter( dummy )
00673         desc = str( cfilter )
00674         lines = desc.split('; ')
00675         assert len( lines ) == 1
00676         assert lines[0] == 'Subject: foo'

Definition at line 677 of file test_PortalFolder.py.

00677 
00678     def test_Subject2( self ):
00679         # Now test with mutli-valued
00680 
00681         from Products.CMFCore.PortalFolder import ContentFilter
00682 
00683         cfilter = ContentFilter( Subject=('foo', 'bar' ) )
00684         dummy = self.dummy
00685         assert not cfilter( dummy )
00686         dummy.subject = ( 'baz', )
00687         assert not cfilter( dummy )
00688         dummy.subject = ( 'bar', )
00689         assert cfilter( dummy )
00690         dummy.subject = ( 'foo', )
00691         assert cfilter( dummy )
00692         dummy.subject = ( 'foo', 'bar', )
00693         assert cfilter( dummy )
00694         desc = str( cfilter )
00695         lines = desc.split('; ')
00696         assert len( lines ) == 1
00697         assert lines[0] == 'Subject: foo, bar'

Definition at line 605 of file test_PortalFolder.py.

00605 
00606     def test_Title( self ):
00607 
00608         from Products.CMFCore.PortalFolder import ContentFilter
00609 
00610         cfilter = ContentFilter( Title='foo' )
00611         dummy = self.dummy
00612         assert not cfilter( dummy )
00613         dummy.title = 'asdf'
00614         assert not cfilter( dummy )
00615         dummy.title = 'foolish'
00616         assert cfilter( dummy )
00617         dummy.title = 'ohsofoolish'
00618         assert cfilter( dummy )
00619         desc = str( cfilter )
00620         lines = desc.split('; ')
00621         assert len( lines ) == 1
00622         assert lines[0] == 'Title: foo'

Definition at line 560 of file test_PortalFolder.py.

00560 
00561     def test_Type( self ):
00562 
00563         from Products.CMFCore.PortalFolder import ContentFilter
00564 
00565         cfilter = ContentFilter( Type='foo' )
00566         dummy = self.dummy
00567         assert not cfilter( dummy )
00568         cfilter = ContentFilter( Type='Dummy Content Title' )
00569         assert cfilter( dummy )
00570         desc = str( cfilter )
00571         lines = desc.split('; ')
00572         assert len( lines ) == 1
00573         assert lines[0] == 'Type: Dummy Content Title'
00574 
00575         cfilter = ContentFilter( Type=( 'foo', 'bar' ) )
00576         dummy = self.dummy
00577         assert not cfilter( dummy )
00578         cfilter = ContentFilter( Type=( 'Dummy Content Title',
00579                                         'something else' ) )
00580         assert cfilter( dummy )
00581         desc = str( cfilter )
00582         lines = desc.split('; ')
00583         assert len( lines ) == 1
00584         assert lines[0] == 'Type: Dummy Content Title, something else'


Member Data Documentation

Definition at line 547 of file test_PortalFolder.py.


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