[Zope-CVS] CVS: Packages/pypes/pypes/tests - test_extent.py:1.4

Casey Duncan casey at zope.com
Wed Feb 11 00:36:03 EST 2004


Update of /cvs-repository/Packages/pypes/pypes/tests
In directory cvs.zope.org:/tmp/cvs-serv28967/tests

Modified Files:
	test_extent.py 
Log Message:
Finish extent map tests


=== Packages/pypes/pypes/tests/test_extent.py 1.3 => 1.4 ===
--- Packages/pypes/pypes/tests/test_extent.py:1.3	Tue Feb 10 01:25:37 2004
+++ Packages/pypes/pypes/tests/test_extent.py	Wed Feb 11 00:36:02 2004
@@ -192,7 +192,8 @@
         from pypes import services
         from pypes.identity import IdRegisteredMessage
         ident = obj._pypes_id_ = self._nextid
-        self._objs[id] = obj
+        self._objs[ident] = obj
+        obj._p_jar = self._conn
         self._nextid += 1
         services.event(self._conn).send(IdRegisteredMessage(obj, ident))
     
@@ -200,9 +201,9 @@
         from pypes import services
         from pypes.identity import IdUnregisteredMessage
         ident = obj._pypes_id_
-        del self._objs[id]
-        del obj._pypes_id_
         services.event(self._conn).send(IdUnregisteredMessage(obj, ident))
+        del self._objs[ident]
+        del obj._pypes_id_
 
 class TestExtent:
     
@@ -214,12 +215,12 @@
     def __len__(self):
         length = 0
         for key in self._keys.keys():
-            length += len(self._idsets[key])
+            length += len(self._idsets.get(key, ()))
         return length
     
     def __contains__(self, obj):
         for key in self._keys.keys():
-            if obj in self._idsets[key]:
+            if obj in self._idsets.get(key, ()):
                 return True
         return False
 
@@ -261,12 +262,14 @@
         self.assertEqual(len(extent), 1)
         self.failUnless(obj in extent)
         
-    def xtestAddObjectMultipleBases(self):
+    def testAddObjectMultipleBases(self):
         obj = self._makeObj(SplatClass)
+        for cls in (BarClass, BazClass, SplatClass):
+            extent = self.cemap[cls]
+            self.failUnless(obj in extent)
+            self.assertEqual(len(extent), 1)
         classes = [ex.key for ex in self.cemap]
-        self.assertEqual(sort(classes), sort([BarClass, BazClass, SplatClass]))
-        for cls in classes:
-            self.assertEqual(len(self.cemap[cls]), 1)
+        self.assertEqual(classes, [SplatClass])
     
     def testAddManyObjects1Class(self):
         objs = [self._makeObj(BarClass) for i in range(10)]
@@ -277,7 +280,7 @@
         for ob in objs:
             self.failUnless(ob in extent)
     
-    def xtestAddManyObjectsMultipleClasses(self):
+    def testAddManyObjectsMultipleClasses(self):
         objs = []
         for i in range(5):
             for cls in [FooClass, BarClass, BazClass, SplatClass]:
@@ -288,7 +291,28 @@
         self.assertEqual(len(self.cemap[FooClass]), 5)
         self.assertEqual(len(self.cemap[BarClass]), 15)
         self.assertEqual(len(self.cemap[BazClass]), 10)
-        self.assertEqual(len(self.cemap[SplatClass]), 10)
+        self.assertEqual(len(self.cemap[SplatClass]), 5)
+    
+    def testRemoveObject(self):
+        from pypes import services
+        obj = self._makeObj(FooClass)
+        extent = self.cemap[FooClass]
+        self.assertEqual(len(extent), 1)
+        self.identity.remove(obj)
+        self.assertEqual(len(extent), 0)
+    
+    def testAddRemoveMany(self):
+        objs = []
+        for i in range(5):
+            for cls in [FooClass, BarClass, BazClass, SplatClass]:
+                objs.append(self._makeObj(cls))
+        extents = [self.cemap[ex] 
+                   for ex in [FooClass, BarClass, BazClass, SplatClass]]
+        for ob in objs:
+            self.identity.remove(ob)
+        for ex in extents:
+            self.assertEqual(len(ex), 0)
+             
         
 if __name__ == '__main__':
     unittest.main()




More information about the Zope-CVS mailing list