Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions
CMFDefault.tests.test_Portal.CMFSiteTests Class Reference

List of all members.

Public Member Functions

def afterSetUp
def test_new
def test_MetadataCataloguing
def test_DocumentEditCataloguing
def test_ImageEditCataloguing
def test_FileEditCataloguing
def test_LinkEditCataloguing
def test_NewsItemEditCataloguing

Static Public Attributes

 layer = FunctionalLayer

Private Member Functions

def _makeContent

Detailed Description

Definition at line 29 of file test_Portal.py.


Member Function Documentation

def CMFDefault.tests.test_Portal.CMFSiteTests._makeContent (   self,
  site,
  portal_type,
  id = 'document',
  kw 
) [private]

Definition at line 33 of file test_Portal.py.

00033 
00034     def _makeContent( self, site, portal_type, id='document', **kw ):
00035         newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
00036 
00037         site.invokeFactory( type_name=portal_type, id=id )
00038         content = getattr( site, id )
00039 
00040         if getattr( aq_base( content ), 'editMetadata', None ) is not None:
00041             content.editMetadata( **kw )
00042 
00043         return content

Here is the caller graph for this function:

Definition at line 44 of file test_Portal.py.

00044 
00045     def afterSetUp(self):
00046         setSite(self.app.site)

Definition at line 101 of file test_Portal.py.

00101 
00102     def test_DocumentEditCataloguing( self ):
00103         site = self.app.site
00104         catalog = site.portal_catalog
00105 
00106         doc = self._makeContent( site
00107                                , portal_type='Document'
00108                                , title='Foo' )
00109 
00110         rid = catalog._catalog.paths.keys()[0]
00111 
00112         doc.setTitle( 'Bar' )   # doesn't reindex
00113         self.assertEqual( _getMetadata( catalog, rid ), 'Foo' )
00114 
00115         doc.edit( text_format='structured-text'
00116                 , text='Some Text Goes Here\n\n   A paragraph\n   for you.'
00117                 )
00118         self.assertEqual( _getMetadata( catalog, rid ), 'Bar' )

Here is the call graph for this function:

Definition at line 135 of file test_Portal.py.

00135 
00136     def test_FileEditCataloguing( self ):
00137         site = self.app.site
00138         catalog = site.portal_catalog
00139 
00140         doc = self._makeContent( site
00141                                , portal_type='File'
00142                                , title='Foo' )
00143 
00144         rid = catalog._catalog.paths.keys()[0]
00145 
00146         doc.setTitle( 'Bar' )   # doesn't reindex
00147         self.assertEqual( _getMetadata( catalog, rid ), 'Foo' )
00148 
00149         doc.edit( '%PDF-1.2\r' )
00150         self.assertEqual( _getMetadata( catalog, rid ), 'Bar' )

Here is the call graph for this function:

Definition at line 119 of file test_Portal.py.

00119 
00120     def test_ImageEditCataloguing( self ):
00121         site = self.app.site
00122         catalog = site.portal_catalog
00123 
00124         doc = self._makeContent( site
00125                                , portal_type='Image'
00126                                , title='Foo' )
00127 
00128         rid = catalog._catalog.paths.keys()[0]
00129 
00130         doc.setTitle( 'Bar' )   # doesn't reindex
00131         self.assertEqual( _getMetadata( catalog, rid ), 'Foo' )
00132 
00133         doc.edit( 'GIF89a' )
00134         self.assertEqual( _getMetadata( catalog, rid ), 'Bar' )

Here is the call graph for this function:

Definition at line 151 of file test_Portal.py.

00151 
00152     def test_LinkEditCataloguing( self ):
00153         site = self.app.site
00154         catalog = site.portal_catalog
00155 
00156         doc = self._makeContent( site
00157                                , portal_type='Link'
00158                                , title='Foo' )
00159 
00160         rid = catalog._catalog.paths.keys()[0]
00161 
00162         doc.setTitle( 'Bar' )   # doesn't reindex
00163         self.assertEqual( _getMetadata( catalog, rid ), 'Foo' )
00164 
00165         doc.edit( 'http://www.example.com' )
00166         self.assertEqual( _getMetadata( catalog, rid ), 'Bar' )

Here is the call graph for this function:

Definition at line 52 of file test_Portal.py.

00052 
00053     def test_MetadataCataloguing( self ):
00054         site = self.app.site
00055         catalog = site.portal_catalog
00056         ttool = site.portal_types
00057         uid_handler = getattr(site, 'portal_uidhandler', None)
00058 
00059         portal_types = [ x for x in ttool.listContentTypes()
00060                            if x not in ( 'Discussion Item'
00061                                        , 'CMF BTree Folder'
00062                                        , 'Folder'
00063                                        , 'Topic'
00064                                        ) ]
00065 
00066         self.assertEqual( len( catalog ), 0 )
00067 
00068         for portal_type in portal_types:
00069 
00070             doc = self._makeContent( site
00071                                    , portal_type=portal_type
00072                                    , title='Foo' )
00073 
00074             # in case of the CMFUid beeing installed this test
00075             # indexes also the site root because the 'Favorite'
00076             # references it by unique id
00077             isUidEnabledFavorite = uid_handler and portal_type == 'Favorite'
00078             if isUidEnabledFavorite:
00079                 self.assertEqual( len( catalog ), 2 )
00080             else:
00081                 self.assertEqual( len( catalog ), 1 )
00082 
00083             # find the right brain
00084             rid = catalog._catalog.paths.keys()[0]
00085             title = _getMetadata( catalog, rid )
00086             if isUidEnabledFavorite and title == 'Portal':
00087                 rid = catalog._catalog.paths.keys()[1]
00088                 title = _getMetadata( catalog, rid )
00089             self.assertEqual( title, 'Foo' )
00090 
00091             doc.editMetadata( title='Bar' )
00092             self.assertEqual( _getMetadata( catalog, rid ), 'Bar' )
00093 
00094             site._delObject( doc.getId() )
00095 
00096             if isUidEnabledFavorite:
00097                 # unindex the site root by hand
00098                 catalog.unindexObject(site)
00099 
00100             self.assertEqual( len( catalog ), 0 )

Here is the call graph for this function:

Definition at line 47 of file test_Portal.py.

00047 
00048     def test_new( self ):
00049         catalog = self.app.site.portal_catalog
00050 
00051         self.assertEqual(len(catalog), 0)

Definition at line 167 of file test_Portal.py.

00167 
00168     def test_NewsItemEditCataloguing( self ):
00169         site = self.app.site
00170         catalog = site.portal_catalog
00171 
00172         doc = self._makeContent( site
00173                                , portal_type='News Item'
00174                                , title='Foo' )
00175 
00176         rid = catalog._catalog.paths.keys()[0]
00177 
00178         doc.setTitle( 'Bar' )   # doesn't reindex
00179         self.assertEqual( _getMetadata( catalog, rid ), 'Foo' )
00180 
00181         doc.edit( '<h1>Extra!</h1>' )
00182         self.assertEqual( _getMetadata( catalog, rid ), 'Bar' )
00183 

Here is the call graph for this function:


Member Data Documentation

Definition at line 31 of file test_Portal.py.


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