[CMF-checkins] CVS: CMF/CMFCore/tests - test_PortalFolder.py:1.20 test_TypesTool.py:1.17 test_WorkflowTool.py:1.5

Florent Guillaume fg@nuxeo.com
Sun, 4 Aug 2002 18:59:44 -0400


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

Modified Files:
	test_PortalFolder.py test_TypesTool.py test_WorkflowTool.py 
Log Message:
Improved tests to make the distinction between meta_type, portal_type
the and portal type's title.


=== CMF/CMFCore/tests/test_PortalFolder.py 1.19 => 1.20 ===
                                   , filter_content_types=0
                                   )
                              )
-        types_tool._setObject( 'Dummy', DummyFTI )
+        types_tool._setObject( 'Dummy Content', DummyFTI )
 
     def _makeOne( self, id ):
         return PortalFolder( id ).__of__( self.root )
@@ -46,13 +46,13 @@
 
         self.failIf( 'foo' in f.objectIds() )
 
-        f.invokeFactory( type_name='Dummy', id='foo' )
+        f.invokeFactory( type_name='Dummy Content', id='foo' )
 
         self.failUnless( 'foo' in f.objectIds() )
         foo = f.foo
         self.assertEqual( foo.getId(), 'foo' )
-        self.assertEqual( foo.getPortalTypeName(), 'Dummy' )
-        self.assertEqual( foo.Type(), 'Dummy Content' )
+        self.assertEqual( foo._getPortalTypeName(), 'Dummy Content' )
+        self.assertEqual( foo.Type(), 'Dummy Content Title' )
 
     def test_invokeFactory_disallowed_type( self ):
 
@@ -69,7 +69,8 @@
         self.failUnless( 'sub' in f.objectIds() )
 
         self.assertRaises( ValueError
-                         , f.invokeFactory, type_name='Dummy', id='foo' )
+                         , f.invokeFactory
+                         , type_name='Dummy Content', id='foo' )
 
 
 class PortalFolderTests( SecurityTest ):
@@ -265,7 +266,7 @@
 
         # First, test default behavior
         test.manage_addFolder( id='simple', title='Simple' )
-        self.assertEqual( test.simple.getPortalTypeName(), 'Folder' )
+        self.assertEqual( test.simple._getPortalTypeName(), 'Folder' )
         self.assertEqual( test.simple.Type(), 'Folder or Directory' )
         self.assertEqual( test.simple.getId(), 'simple' )
         self.assertEqual( test.simple.Title(), 'Simple' )
@@ -293,7 +294,7 @@
         self.root.grabbed = Grabbed( test )
 
         test.manage_addFolder( id='indirect', title='Indirect' )
-        self.assertEqual( test.indirect.getPortalTypeName(), 'Grabbed' )
+        self.assertEqual( test.indirect._getPortalTypeName(), 'Grabbed' )
         self.assertEqual( test.indirect.Type(), 'Grabbed Content' )
         self.assertEqual( test.indirect.getId(), 'indirect' )
         self.assertEqual( test.indirect.Title(), 'Indirect' )
@@ -306,7 +307,7 @@
 
         self.root._setObject( 'portal_types', TypesTool() )
         types_tool = self.root.portal_types
-        types_tool._setObject( 'Dummy', DummyFTI )
+        types_tool._setObject( 'Dummy Content', DummyFTI )
 
         self.root._setObject( 'portal_catalog', CatalogTool() )
         catalog = self.root.portal_catalog
@@ -388,22 +389,40 @@
         cfilter = ContentFilter( Type='foo' )
         dummy = self.dummy
         assert not cfilter( dummy )
-        cfilter = ContentFilter( Type='Dummy Content' )
+        cfilter = ContentFilter( Type='Dummy Content Title' )
         assert cfilter( dummy )
         desc = str( cfilter )
         lines = desc.split('; ')
         assert len( lines ) == 1
-        assert lines[0] == 'Type: Dummy Content'
+        assert lines[0] == 'Type: Dummy Content Title'
 
         cfilter = ContentFilter( Type=( 'foo', 'bar' ) )
         dummy = self.dummy
         assert not cfilter( dummy )
-        cfilter = ContentFilter( Type=( 'Dummy Content', 'something else' ) )
+        cfilter = ContentFilter( Type=( 'Dummy Content Title',
+                                        'something else' ) )
         assert cfilter( dummy )
         desc = str( cfilter )
         lines = desc.split('; ')
         assert len( lines ) == 1
-        assert lines[0] == 'Type: Dummy Content, something else'
+        assert lines[0] == 'Type: Dummy Content Title, something else'
+
+    def test_portal_type( self ):
+        cfilter = ContentFilter( portal_type='some_pt' )
+        dummy = self.dummy
+        assert not cfilter( dummy )
+        dummy.portal_type = 'asdf'
+        assert not cfilter( dummy )
+        dummy.portal_type = 'some_ptyyy'
+        assert not cfilter( dummy )
+        dummy.portal_type = 'xxxsome_ptyyy'
+        assert not cfilter( dummy )
+        dummy.portal_type = 'some_pt'
+        assert cfilter( dummy )
+        desc = str( cfilter )
+        lines = desc.split('; ')
+        assert len( lines ) == 1
+        assert lines[0] == 'Portal Type: some_pt'
 
     def test_Title( self ):
         cfilter = ContentFilter( Title='foo' )


=== CMF/CMFCore/tests/test_TypesTool.py 1.16 => 1.17 ===
 
         root._setObject( 'portal_types', TypesTool() )
         tool = root.portal_types
-        tool._setObject( 'Dummy', DummyFTI ) 
+        tool._setObject( 'Dummy Content', DummyFTI ) 
     
     def test_processActions( self ):
         """
@@ -41,7 +41,7 @@
         """
         self.root._setObject( 'portal', PortalFolder( 'portal', '' ) )
         portal = self.root.portal
-        portal.invokeFactory( 'Dummy', 'actions_dummy' )
+        portal.invokeFactory( 'Dummy Content', 'actions_dummy' )
         dummy = portal._getOb( 'actions_dummy' )
 
         # so we can traverse to it:


=== CMF/CMFCore/tests/test_WorkflowTool.py 1.4 => 1.5 ===
 
 class DummyContent( Dummy ):
 
-    meta_type = 'DummyContent'
-    portal_type = 'DummyContentPT'
+    meta_type = 'Dummy'
     _isPortalContent = 1
+    def _getPortalTypeName(self): return 'Dummy Content'
 
 class DummyNotReallyContent( Dummy ):
 
-    meta_type = 'DummyContentPT'
+    meta_type = 'Dummy Content'
 
 class DummyTypeInfo( Dummy ):
 
@@ -97,11 +97,11 @@
 class DummyTypesTool( SimpleItem ):
 
     def listTypeInfo( self ):
-        return [ DummyTypeInfo( 'DummyContentPT' ) ]
+        return [ DummyTypeInfo( 'Dummy Content' ) ]
 
     def getTypeInfo( self, ob ):
-        if getattr( ob, 'meta_type', None ) is 'DummyContent':
-            return DummyTypeInfo( 'DummyContentPT' )
+        if getattr( ob, 'meta_type', None ) is 'Dummy':
+            return DummyTypeInfo( 'Dummy Content' )
         return None
         
 
@@ -140,7 +140,7 @@
     def _makeWithTypesAndChain( self ):
 
         tool = self._makeWithTypes()
-        tool.setChainForPortalTypes( ( 'DummyContentPT', ), ( 'a', 'b' ) )
+        tool.setChainForPortalTypes( ( 'Dummy Content', ), ( 'a', 'b' ) )
         return tool
 
     def test_interface( self ):