[Zope-CVS] CVS: Packages/pypes/pypes/tests - test_query.py:1.8

Casey Duncan casey at zope.com
Thu Apr 29 22:45:14 EDT 2004


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

Modified Files:
	test_query.py 
Log Message:
Add intersect_input_map() function


=== Packages/pypes/pypes/tests/test_query.py 1.7 => 1.8 ===
--- Packages/pypes/pypes/tests/test_query.py:1.7	Tue Apr 27 23:18:12 2004
+++ Packages/pypes/pypes/tests/test_query.py	Thu Apr 29 22:45:11 2004
@@ -69,7 +69,7 @@
 class Bar(TestClass):
     pass
 
-class TestUtilities(unittest.TestCase):
+class TestPrimitives(unittest.TestCase):
     
     def test_union_input_maps(self):
         from pypes.query import union_input_maps
@@ -93,6 +93,31 @@
         map1 = {'larry':Set(), 'moe':Set(), 'curly':Set()}
         map2 = {'larry':Set(), 'moe':Set(), 'shemp':Set()}
         self.assertRaises(AssertionError, union_input_maps, map1, map2)
+    
+    def test_intersect_input_maps(self):
+        from pypes.query import intersect_input_maps
+        map1 = {'jerry': Set((1,2,3)), 'george': Set(('blue', 'red'))}
+        map2 = {'jerry': Set((3,4,5)), 'george': map1['george']}
+        intersect = intersect_input_maps(map1, map2)
+        self.assertEqual(Set(intersect), Set(map1))
+        self.assertEqual(
+            intersect['jerry'], map1['jerry'].intersection(map2['jerry']))
+        self.assertEqual(
+            intersect['george'], map1['george'].intersection(map2['george']))
+        self.failIf(intersect is map1 or intersect is map2)
+        
+    def test_intersect_input_map_to_self(self):
+        from pypes.query import intersect_input_maps
+        inmap = {'pee wee': Set(('loner', 'rebel'))}
+        intersect = intersect_input_maps(inmap, inmap)
+        self.assertEqual(inmap, intersect)
+        self.failIf(inmap is intersect)
+    
+    def test_intersect_input_maps_fails_with_different_inputs(self):
+        from pypes.query import intersect_input_maps
+        map1 = {'larry':Set(), 'moe':Set(), 'curly':Set()}
+        map2 = {'larry':Set(), 'moe':Set(), 'shemp':Set()}
+        self.assertRaises(AssertionError, intersect_input_maps, map1, map2)
     
 class TestCartProduct(unittest.TestCase):
     




More information about the Zope-CVS mailing list