[CMF-checkins] CVS: Products/CMFDefault/tests - test_Portal.py:1.6

Grégoire Weber zope.org at incept.ch
Thu Aug 5 11:39:29 EDT 2004


Update of /cvs-repository/Products/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv30178/tests

Modified Files:
	test_Portal.py 
Log Message:
- adding a unique id to the remote object of a favorite didn't work in the favorites '__init__' method as 'self' was not yet wrapped thus the uid tools were not found. The solution was to move that code to the manage_afterAdd hook. Unfortunately after this change 'test_MetadataCataloguing' in 'test_portal.py' failed because the favorite also cataloged the site root (which is correct) but the test assumed only the content type got catalgoed and thus failed. So the unit test had to be updated accordingly.


=== Products/CMFDefault/tests/test_Portal.py 1.5 => 1.6 ===
--- Products/CMFDefault/tests/test_Portal.py:1.5	Mon Apr 26 08:14:18 2004
+++ Products/CMFDefault/tests/test_Portal.py	Thu Aug  5 11:39:29 2004
@@ -54,6 +54,7 @@
         site = self._makeSite()
         catalog = site.portal_catalog
         site.portal_membership.memberareaCreationFlag = 0
+        uid_handler = getattr(site, 'portal_uidhandler', None)
 
         portal_types = [ x for x in site.portal_types.listContentTypes()
                            if x not in ( 'Discussion Item'
@@ -68,15 +69,33 @@
             doc = self._makeContent( site
                                    , portal_type=portal_type
                                    , title='Foo' )
-            self.assertEqual( len( catalog ), 1 )
 
+            # in case of the CMFUid beeing installed this test
+            # indexes also the site root because the 'Favorite'
+            # references it by unique id
+            isUidEnabledFavorite = uid_handler and portal_type == 'Favorite'
+            if isUidEnabledFavorite:
+                self.assertEqual( len( catalog ), 2 )
+            else:
+                self.assertEqual( len( catalog ), 1 )
+
+            # find the right brain
             rid = catalog._catalog.paths.keys()[0]
-            self.assertEqual( _getMetadata( catalog, rid ), 'Foo' )
+            title = _getMetadata( catalog, rid )
+            if isUidEnabledFavorite and title == 'Portal':
+                rid = catalog._catalog.paths.keys()[1]
+                title = _getMetadata( catalog, rid )
+            self.assertEqual( title, 'Foo' )
 
             doc.editMetadata( title='Bar' )
             self.assertEqual( _getMetadata( catalog, rid ), 'Bar' )
 
             site._delObject( doc.getId() )
+            
+            if isUidEnabledFavorite:
+                # unindex the site root by hand
+                catalog.unindexObject(site)
+                
             self.assertEqual( len( catalog ), 0 )
 
     def test_DocumentEditCataloguing( self ):



More information about the CMF-checkins mailing list