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

Casey Duncan casey at zope.com
Wed May 26 00:32:50 EDT 2004


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

Modified Files:
	test_query.py 
Log Message:
Finish ActualizedResult tests
Finish Join.iterResult() so that it can handle names not joined


=== Packages/pypes/pypes/tests/test_query.py 1.12 => 1.13 ===
--- Packages/pypes/pypes/tests/test_query.py:1.12	Fri May 14 00:38:32 2004
+++ Packages/pypes/pypes/tests/test_query.py	Wed May 26 00:32:49 2004
@@ -187,6 +187,31 @@
             count += 1
         self.assertEqual(count, len(self.foos))
     
+    def test_iter_three_with_static(self):
+        from pypes.query import CartProduct
+        inputs = {'one': [1,2,3,4,5,6], 
+                  'two': list('ABCDEFGHIJKLMNOP'),
+                  'three': [2,4,6,8,10]}
+        cp = CartProduct(inputs)
+        count = 0
+        for one, two, three in cp.iterResult('one', 'two', 'three', two='C'):
+            self.assertEqual(two, 'C')
+            count += 1
+        self.assertEqual(count, len(inputs['one']) * len(inputs['three']))
+        count = 0
+        for two, three, one in cp.iterResult(
+            'two', 'three', 'one', two='C', one=2):
+            self.assertEqual(two, 'C')
+            self.assertEqual(one, 2)
+            count += 1
+        self.assertEqual(count, len(inputs['three']))
+    
+    def test_iter_with_static_fails(self):
+        self.assertRaises(
+            AssertionError, self.cp.iterResult('foo', 'bar', bar=Bar()).next)
+        self.assertRaises(
+            KeyError, self.cp.iterResult('foo', 'bar', baz=None).next)
+    
     def test_union_cp_with_cp(self):
         from pypes.query import CartProduct
         cp1 = CartProduct(
@@ -498,11 +523,11 @@
     def test_select_inputs_not_joined(self):
         from pypes.query import Join
         j = Join(self.inputs, DummyExpr(expr='a[-1] == b', names=['a', 'b']))
-        expected = sort([(a, c) for a in self.inputs['a'] 
+        expected = Set([(a, c) for a in self.inputs['a'] 
                                 for b in self.inputs['b']
                                 for c in self.inputs['c']
                                 if a[-1] == b])
-        self.assertEqual(sort(j.iterResult('a', 'c')), expected)
+        self.assertEqual(Set(j.iterResult('a', 'c')), expected)
     
     def test_union_joins_one_common_input(self):
         from pypes.query import Join
@@ -530,6 +555,22 @@
     def test_interface(self):
         from pypes.interfaces import IPartialResult
         self.failUnless(verifyObject(IPartialResult, self.result))
+        
+    def test_can_process(self):
+        from pypes.query import ActualizedResult
+        ActualizedResult(self.inputs, DummyExpr(expr="a == 10", names=['a']))
+        ActualizedResult(self.inputs, 
+            DummyExpr(expr="a == 10 or a == 30", names=['a']))
+        ActualizedResult(self.inputs, 
+            DummyExpr(expr="a == 10 and b in ('a','b')", names=['a', 'b']))
+    
+    def test_cant_process(self):
+        from pypes.query import ActualizedResult
+        from pypes.exceptions import CantProcess
+        self.assertRaises(CantProcess, ActualizedResult, 
+            self.inputs, DummyExpr(expr="a == b", names=['a', 'b']))
+        self.assertRaises(CantProcess, ActualizedResult, 
+            self.inputs, DummyExpr(expr="a.startswith(b)", names=['a', 'b']))
         
     def test_input_map(self):
         expected = {




More information about the Zope-CVS mailing list