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

Casey Duncan casey at zope.com
Mon Feb 16 00:17:53 EST 2004


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

Modified Files:
	test_extent.py 
Log Message:
Simplify and generalize constructor of extent service


=== Packages/pypes/pypes/tests/test_extent.py 1.6 => 1.7 ===
--- Packages/pypes/pypes/tests/test_extent.py:1.6	Sun Feb 15 23:44:58 2004
+++ Packages/pypes/pypes/tests/test_extent.py	Mon Feb 16 00:17:51 2004
@@ -22,7 +22,7 @@
 from zope.interface.exceptions import DoesNotImplement
 from zope.interface.verify import verifyObject
 from pypes.interfaces import IExtentMap, IExtentService
-from pypes.tests.common import TestConnection, sort
+from pypes.tests.common import TestConnection, sort, PypesTestCase
 from BTrees.OOBTree import OOBTree, OOTreeSet
 
 class FooClass:
@@ -70,27 +70,13 @@
     def update(self):
         pass
 
-def makeClassMap(self, dbconn):
-    return TestExtentMap(FooClass, BarClass, BazClass)
-
-def makeInterfaceMap(self, dbconn):
-    return TestExtentMap(IMoe, ILarry, ICurly)
-
 class TestExtentService(unittest.TestCase):
     
     def setUp(self):
-        self.extent = self.makeExtentService()
-    
-    def makeExtentService(self, **kw):
         from pypes.extent import ExtentService
-        orig_class_map = ExtentService._class_map_factory
-        orig_iface_map = ExtentService._interface_map_factory
-        ExtentService._class_map_factory = makeClassMap
-        ExtentService._interface_map_factory = makeInterfaceMap
-        extent = ExtentService(TestConnection(), **kw)
-        ExtentService._class_map_factory = orig_class_map
-        ExtentService._interface_map_factory = orig_iface_map
-        return extent
+        self.extent = ExtentService(
+            TestExtentMap(FooClass, BarClass, BazClass),
+            TestExtentMap(IMoe, ILarry, ICurly))
     
     def testInterface(self):
         from pypes.interfaces import IExtentService
@@ -141,7 +127,8 @@
         self.assertEqual(sort(all), sort(expected))
         
     def testOnlyClasses(self):
-        self.extent = self.makeExtentService(interface_extents=False)
+        from pypes.extent import ExtentService
+        self.extent = ExtentService(TestExtentMap(FooClass, BarClass, BazClass))
         self.testGetClass()
         self.testContainsClass()
         all = list(iter(self.extent))
@@ -151,7 +138,8 @@
         self.assertRaises(TypeError, self.testContainsInterface)
         
     def testOnlyInterfaces(self):
-        self.extent = self.makeExtentService(class_extents=False)
+        from pypes.extent import ExtentService
+        self.extent = ExtentService(TestExtentMap(IMoe, ILarry, ICurly))
         self.testGetInterface()
         self.testContainsInterface()
         all = list(iter(self.extent))
@@ -160,9 +148,9 @@
         self.assertRaises(TypeError, self.testGetClass)
         self.assertRaises(TypeError, self.testContainsClass)
         
-    def testMustEnableClassesOrInterfaces(self):
-        self.assertRaises(AssertionError, self.makeExtentService,
-            interface_extents=False, class_extents=False)
+    def testMustHaveMap(self):
+        from pypes.extent import ExtentService
+        self.assertRaises(AssertionError, ExtentService)
 
 class DummyEventService:
     """Test Event Service Scaffold"""
@@ -496,10 +484,8 @@
         self.failUnless(bar_extent.issubset(foo_extent))
         self.failUnless(bar_extent.issuperset(foo_extent))
         self.failUnless(foo_extent.issuperset(bar_extent))
-        self.failUnless(foo_extent.issubset(bar_extent))        
-        
-
-# XXX add tests for extent to idset operations
+        self.failUnless(foo_extent.issubset(bar_extent))
+    
         
 if __name__ == '__main__':
     unittest.main()




More information about the Zope-CVS mailing list