[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/Folder/tests - testFolderLimit.py:1.1.4.2 testLoadedFolder.py:1.1.4.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 15:34:50 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/Folder/tests
In directory cvs.zope.org:/tmp/cvs-serv5490/lib/python/Zope/App/OFS/Content/Folder/tests

Modified Files:
      Tag: Zope-3x-branch
	testFolderLimit.py testLoadedFolder.py 
Log Message:
Implemented 

http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/IContainerPythonification

Along the way:

- Converted most uses of has_key to use in.

- Fixed a bug in Interface names and namesAndDescriptions methods 
  that caused base class attributes to be missed.



=== Zope3/lib/python/Zope/App/OFS/Content/Folder/tests/testFolderLimit.py 1.1.4.1 => 1.1.4.2 ===
 
         # A second one should fit in
-        self.failIf(loadedfolder.setObject('object2', Object()))
+        loadedfolder.setObject('object2', Object())
         
         # But with 3 go on strike
         self.assertRaises( FolderLimitExceededError,


=== Zope3/lib/python/Zope/App/OFS/Content/Folder/tests/testLoadedFolder.py 1.1.4.1 => 1.1.4.2 ===
 
         folder = self._makeFolder()
-        self.failIf( folder.objectIds()         )
-        self.failIf( folder.objectValues()      )
-        self.failIf( folder.objectItems()       )
-        self.failIf( folder.objectCount()       )
-        self.failIf( folder.hasObject( 'foo' )  )
+        self.failIf( folder.keys()         )
+        self.failIf( folder.values()      )
+        self.failIf( folder.items()       )
+        self.failIf( len(folder)       )
+        self.failIf( 'foo' in folder)
 
-        self.assertEquals( folder.getObject( 'foo', None ), None )
-        self.assertRaises( KeyError, folder.getObject, 'foo' )
+        self.assertEquals( folder.get( 'foo', None ), None )
+        self.assertRaises( KeyError, folder.__getitem__, 'foo' )
 
-        self.assertRaises( KeyError, folder.delObject, 'foo' )
+        self.assertRaises( KeyError, folder.__delitem__, 'foo' )
 
     def testOneItem( self ):
 
@@ -50,44 +50,44 @@
         foo = []
         folder.setObject( 'foo', foo )
 
-        self.assertEquals( len( folder.objectIds() ), 1             )
-        self.assertEquals( folder.objectIds()[0], 'foo'             )
-        self.assertEquals( len( folder.objectValues() ), 1          )
-        self.assertEquals( folder.objectValues()[0], foo            )
-        self.assertEquals( len( folder.objectItems() ), 1           )
-        self.assertEquals( folder.objectItems()[0], ( 'foo', foo )  )
-        self.assertEquals( folder.objectCount(), 1                  )
+        self.assertEquals( len( folder.keys() ), 1             )
+        self.assertEquals( folder.keys()[0], 'foo'             )
+        self.assertEquals( len( folder.values() ), 1          )
+        self.assertEquals( folder.values()[0], foo            )
+        self.assertEquals( len( folder.items() ), 1           )
+        self.assertEquals( folder.items()[0], ( 'foo', foo )  )
+        self.assertEquals( len(folder), 1                  )
 
-        self.failUnless( folder.hasObject( 'foo' )  )
-        self.failIf( folder.hasObject( 'bar' ) )
+        self.failUnless('foo' in folder)
+        self.failIf('bar' in folder)
 
-        self.assertEquals( folder.getObject( 'foo', None ), foo )
-        self.assertEquals( folder.getObject( 'foo' ), foo )
+        self.assertEquals( folder.get( 'foo', None ), foo )
+        self.assertEquals( folder['foo'], foo )
 
-        self.assertRaises( KeyError, folder.getObject, 'qux' )
+        self.assertRaises( KeyError, folder.__getitem__, 'qux' )
 
         foo2 = []
         folder.setObject( 'foo', foo )
 
-        self.assertEquals( len( folder.objectIds() ), 1             )
-        self.assertEquals( folder.objectIds()[0], 'foo'             )
-        self.assertEquals( len( folder.objectValues() ), 1          )
-        self.assertEquals( folder.objectValues()[0], foo2           )
-        self.assertEquals( len( folder.objectItems() ), 1           )
-        self.assertEquals( folder.objectItems()[0], ( 'foo', foo2 ) )
-        self.assertEquals( folder.objectCount(), 1                  )
-
-        folder.delObject( 'foo' )
-
-        self.failIf( folder.objectIds()         )
-        self.failIf( folder.objectValues()      )
-        self.failIf( folder.objectItems()       )
-        self.failIf( folder.objectCount()       )
-        self.failIf( folder.hasObject( 'foo' )  )
-
-        self.assertRaises( KeyError, folder.getObject, 'foo' )
-        self.assertEquals( folder.getObject( 'foo', None ), None )
-        self.assertRaises( KeyError, folder.delObject, 'foo' )
+        self.assertEquals( len( folder.keys() ), 1             )
+        self.assertEquals( folder.keys()[0], 'foo'             )
+        self.assertEquals( len( folder.values() ), 1          )
+        self.assertEquals( folder.values()[0], foo2           )
+        self.assertEquals( len( folder.items() ), 1           )
+        self.assertEquals( folder.items()[0], ( 'foo', foo2 ) )
+        self.assertEquals( len(folder), 1                  )
+
+        del folder['foo']
+
+        self.failIf( folder.keys()         )
+        self.failIf( folder.values()      )
+        self.failIf( folder.items()       )
+        self.failIf( len(folder)       )
+        self.failIf('foo' in folder)
+
+        self.assertRaises( KeyError, folder.__getitem__, 'foo' )
+        self.assertEquals( folder.get( 'foo', None ), None )
+        self.assertRaises( KeyError, folder.__delitem__, 'foo' )
 
     def testManyItems( self ):
 
@@ -98,69 +98,69 @@
         folder.setObject( 'baz', objects[2] )
         folder.setObject( 'bam', objects[3] )
 
-        self.assertEquals( len( folder.objectIds() ), len( objects ) )
-        self.failUnless( 'foo' in folder.objectIds() )
-        self.failUnless( 'bar' in folder.objectIds() )
-        self.failUnless( 'baz' in folder.objectIds() )
-        self.failUnless( 'bam' in folder.objectIds() )
-
-        self.assertEquals( len( folder.objectValues() ), len( objects ) )
-        self.failUnless( objects[0] in folder.objectValues() )
-        self.failUnless( objects[1] in folder.objectValues() )
-        self.failUnless( objects[2] in folder.objectValues() )
-        self.failUnless( objects[3] in folder.objectValues() )
-
-        self.assertEquals( len( folder.objectItems() ), len( objects ) )
-        self.failUnless( ( 'foo', objects[0] ) in folder.objectItems() )
-        self.failUnless( ( 'bar', objects[1] ) in folder.objectItems() )
-        self.failUnless( ( 'baz', objects[2] ) in folder.objectItems() )
-        self.failUnless( ( 'bam', objects[3] ) in folder.objectItems() )
-
-        self.assertEquals( folder.objectCount(), len( objects ) )
-
-        self.failUnless( folder.hasObject( 'foo' )  )
-        self.failUnless( folder.hasObject( 'bar' )  )
-        self.failUnless( folder.hasObject( 'baz' )  )
-        self.failUnless( folder.hasObject( 'bam' )  )
-        self.failIf( folder.hasObject( 'qux' ) )
-
-        self.assertEquals( folder.getObject( 'foo', None ), objects[0] )
-        self.assertEquals( folder.getObject( 'foo' ),       objects[0] )
-        self.assertEquals( folder.getObject( 'bar', None ), objects[1] )
-        self.assertEquals( folder.getObject( 'bar' ),       objects[1] )
-        self.assertEquals( folder.getObject( 'baz', None ), objects[2] )
-        self.assertEquals( folder.getObject( 'baz' ),       objects[2] )
-        self.assertEquals( folder.getObject( 'bam', None ), objects[3] )
-        self.assertEquals( folder.getObject( 'bam' ),       objects[3] )
-
-        self.assertEquals( folder.getObject( 'qux', None ), None )
-        self.assertRaises( KeyError, folder.getObject, 'qux' )
-
-        folder.delObject( 'foo' )
-        self.assertEquals( folder.objectCount(), len( objects ) - 1 )
-        self.failIf( folder.hasObject( 'foo' )  )
-        self.failIf( 'foo' in folder.objectIds() )
-
-        self.failIf( objects[0] in folder.objectValues() )
-        self.failIf( ( 'foo', objects[0] ) in folder.objectItems() )
-
-        self.assertEquals( folder.getObject( 'foo', None ), None )
-        self.assertRaises( KeyError, folder.getObject, 'foo' )
-
-        self.assertRaises( KeyError, folder.delObject, 'foo' )
-
-        folder.delObject( 'bar' )
-        folder.delObject( 'baz' )
-        folder.delObject( 'bam' )
-
-        self.failIf( folder.objectIds()         )
-        self.failIf( folder.objectValues()      )
-        self.failIf( folder.objectItems()       )
-        self.failIf( folder.objectCount()       )
-        self.failIf( folder.hasObject( 'foo' )  )
-        self.failIf( folder.hasObject( 'bar' )  )
-        self.failIf( folder.hasObject( 'baz' )  )
-        self.failIf( folder.hasObject( 'bam' )  )
+        self.assertEquals( len( folder.keys() ), len( objects ) )
+        self.failUnless( 'foo' in folder.keys() )
+        self.failUnless( 'bar' in folder.keys() )
+        self.failUnless( 'baz' in folder.keys() )
+        self.failUnless( 'bam' in folder.keys() )
+
+        self.assertEquals( len( folder.values() ), len( objects ) )
+        self.failUnless( objects[0] in folder.values() )
+        self.failUnless( objects[1] in folder.values() )
+        self.failUnless( objects[2] in folder.values() )
+        self.failUnless( objects[3] in folder.values() )
+
+        self.assertEquals( len( folder.items() ), len( objects ) )
+        self.failUnless( ( 'foo', objects[0] ) in folder.items() )
+        self.failUnless( ( 'bar', objects[1] ) in folder.items() )
+        self.failUnless( ( 'baz', objects[2] ) in folder.items() )
+        self.failUnless( ( 'bam', objects[3] ) in folder.items() )
+
+        self.assertEquals( len(folder), len( objects ) )
+
+        self.failUnless('foo' in folder)
+        self.failUnless('bar' in folder)
+        self.failUnless('baz' in folder)
+        self.failUnless('bam' in folder)
+        self.failIf('qux' in folder)
+
+        self.assertEquals( folder.get( 'foo', None ), objects[0] )
+        self.assertEquals( folder['foo'],       objects[0] )
+        self.assertEquals( folder.get( 'bar', None ), objects[1] )
+        self.assertEquals( folder['bar'],       objects[1] )
+        self.assertEquals( folder.get( 'baz', None ), objects[2] )
+        self.assertEquals( folder['baz'],       objects[2] )
+        self.assertEquals( folder.get( 'bam', None ), objects[3] )
+        self.assertEquals( folder['bam'],       objects[3] )
+
+        self.assertEquals( folder.get( 'qux', None ), None )
+        self.assertRaises( KeyError, folder.__getitem__, 'qux' )
+
+        del folder['foo']
+        self.assertEquals( len(folder), len( objects ) - 1 )
+        self.failIf( 'foo' in folder)
+        self.failIf( 'foo' in folder.keys() )
+
+        self.failIf( objects[0] in folder.values() )
+        self.failIf( ( 'foo', objects[0] ) in folder.items() )
+
+        self.assertEquals( folder.get( 'foo', None ), None )
+        self.assertRaises( KeyError, folder.__getitem__, 'foo' )
+
+        self.assertRaises( KeyError, folder.__delitem__, 'foo' )
+
+        del folder['bar']
+        del folder['baz']
+        del folder['bam']
+
+        self.failIf( folder.keys()         )
+        self.failIf( folder.values()      )
+        self.failIf( folder.items()       )
+        self.failIf( len(folder)       )
+        self.failIf('foo' in folder)
+        self.failIf('bar' in folder)
+        self.failIf('baz' in folder)
+        self.failIf('bam' in folder)