[CMF-checkins] CVS: CMF/CMFCore/tests/base - dummy.py:1.1.2.3 security.py:1.1.2.2 utils.py:1.1.2.2

Chris Withers chrisw@nipltd.com
Fri, 15 Feb 2002 10:21:10 -0500


Update of /cvs-repository/CMF/CMFCore/tests/base
In directory cvs.zope.org:/tmp/cvs-serv9393/tests/base

Modified Files:
      Tag: ChrisW-refactor_tests-branch
	dummy.py security.py utils.py 
Log Message:
PortalFolder done.

=== CMF/CMFCore/tests/base/dummy.py 1.1.2.2 => 1.1.2.3 ===
 from Products.CMFCore.PortalContent import PortalContent
 from Products.CMFCore.TypesTool import TypeInformation
+from Products.CMFCore.TypesTool import FactoryTypeInformation
 
 class DummyMethod:
     """
@@ -43,10 +44,37 @@
     def reset( self ):
         self.after_add_called = self.before_delete_called = 0
 
-    # WAAAAAAAAA!  we don't want the Database export/import crap in the way.
+    # Make sure normal Database export/import stuff doesn't trip us up.
     def _getCopy( self, container ):        
         return DummyContent( self.id, catalog=self.catalog )
 
+    def _safe_get(self,attr):
+        if self.catalog:
+            return getattr(self,attr,'')
+        else:
+            return getattr(self,attr)
+
+    def Title( self ):
+        return self.title
+
+    def Creator( self ):
+        return self._safe_get('creator')
+
+    def Subject( self ):
+        return self._safe_get('subject')
+
+    def Description( self ):
+        return self.description
+
+    def created( self ):
+        return self._safe_get('created_date')
+
+    def modified( self ):
+        return self._safe_get('modified_date')
+    
+    def Type( self ):
+        return 'Dummy Content'
+
 def addDummy( self, id ):
     """
     Constructor method for DummyContent
@@ -75,6 +103,23 @@
 class DummyTypeInfo(TypeInformation):
     """ Dummy class of type info object """
     meta_type = "Dummy Test Type Info"
+
+DummyFTI = FactoryTypeInformation( 'Dummy',
+                                   meta_type=DummyContent.meta_type,
+                                   product='CMFDefault',
+                                   factory='addDocument',
+                                   actions= ( { 'name'          : 'View',
+                                                'action'        : 'view',
+                                                'permissions'   : ('View', ) },
+                                              { 'name'          : 'View2',
+                                                'action'        : 'view2',
+                                                'permissions'   : ('View', ) },
+                                              { 'name'          : 'Edit',
+                                                'action'        : 'edit',
+                                                'permissions'   : ('forbidden permission',)
+                                                }
+                                              )
+                                   )
 
 class DummyFolder( Implicit ):
     """


=== CMF/CMFCore/tests/base/security.py 1.1.2.1 => 1.1.2.2 ===
 
     def allowed( self, object, object_roles=None ):
+        if object_roles is None:
+            object_roles=()
         for orole in object_roles:
             if orole in self._roles:
                 return 1


=== CMF/CMFCore/tests/base/utils.py 1.1.2.1 => 1.1.2.2 ===
     return suite
 
+def has_path( catalog, path ):
+    """
+        Verify that catalog has an object at path.
+    """
+    rids = map( lambda x: x.data_record_id_, catalog.searchResults() )
+    for rid in rids:
+        if catalog.getpath( rid ) == path:
+            return 1
+    return 0
+