[Zope-CVS] CVS: Packages/pypes/pypes/tests - test_extent.py:1.8
Casey Duncan
casey at zope.com
Mon Feb 16 00:54:05 EST 2004
Update of /cvs-repository/Packages/pypes/pypes/tests
In directory cvs.zope.org:/tmp/cvs-serv28019/tests
Modified Files:
test_extent.py
Log Message:
Add convenience accessor for extent service
Fix bug in _remove in ClassExtentMap when the last instance of a class was removed but subclasses remained
Add some integration tests
=== Packages/pypes/pypes/tests/test_extent.py 1.7 => 1.8 ===
--- Packages/pypes/pypes/tests/test_extent.py:1.7 Mon Feb 16 00:17:51 2004
+++ Packages/pypes/pypes/tests/test_extent.py Mon Feb 16 00:54:03 2004
@@ -485,7 +485,64 @@
self.failUnless(bar_extent.issuperset(foo_extent))
self.failUnless(foo_extent.issuperset(bar_extent))
self.failUnless(foo_extent.issubset(bar_extent))
+
+
+class ITestExtent(PypesTestCase):
+ # Extent integration tests
+ def setUp(self):
+ from pypes.serviceconfig import addService
+ from pypes.extent import ExtentService, ClassExtentMap
+ from pypes import services
+ super(ITestExtent, self).setUp()
+ addService(
+ self.conn, 'extent', ExtentService(ClassExtentMap(self.conn)))
+ self.extent = services.extent(self.conn)
+
+ def _makeObj(self, cls):
+ obj = cls()
+ self.identity.register(obj)
+ return obj
+
+ def testIdentifyCreatesExtents(self):
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], FooClass)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], BarClass)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], BazClass)
+ obj = self._makeObj(BazClass)
+ self.assertEqual(len(self.extent[BazClass]), 1)
+ self.failUnless(obj in self.extent[BazClass])
+ self.assertEqual(len(self.extent[BarClass]), 1)
+ self.failUnless(obj in self.extent[BarClass])
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], FooClass)
+
+ def testRemoveRemovesExtents(self):
+ foo, bar, baz, splat = [self._makeObj(cls)
+ for cls in [FooClass, BarClass, BazClass, SplatClass]]
+ self.assertEqual(len(self.extent[FooClass]), 1)
+ self.assertEqual(len(self.extent[BarClass]), 3)
+ self.assertEqual(len(self.extent[BazClass]), 2)
+ self.assertEqual(len(self.extent[SplatClass]), 1)
+ self.identity.remove(splat)
+ self.assertEqual(len(self.extent[FooClass]), 1)
+ self.assertEqual(len(self.extent[BarClass]), 2)
+ self.assertEqual(len(self.extent[BazClass]), 1)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], SplatClass)
+ self.identity.remove(foo)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], FooClass)
+ self.assertEqual(len(self.extent[BarClass]), 2)
+ self.assertEqual(len(self.extent[BazClass]), 1)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], SplatClass)
+ self.identity.remove(bar)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], FooClass)
+ self.assertEqual(len(self.extent[BarClass]), 1)
+ self.assertEqual(len(self.extent[BazClass]), 1)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], SplatClass)
+ self.identity.remove(baz)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], FooClass)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], BarClass)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], BazClass)
+ self.assertRaises(KeyError, lambda cls: self.extent[cls], SplatClass)
+
if __name__ == '__main__':
unittest.main()
More information about the Zope-CVS
mailing list