[Zope-CVS] CVS: Packages/pypes/pypes/tests - test_query.py:1.3
Casey Duncan
casey at zope.com
Sun Apr 4 00:27:11 EST 2004
Update of /cvs-repository/Packages/pypes/pypes/tests
In directory cvs.zope.org:/tmp/cvs-serv22218/tests
Modified Files:
test_query.py
Log Message:
Implement greater-join query primitive.
Remove optimization reordering join inputs, it's premature at this point
=== Packages/pypes/pypes/tests/test_query.py 1.2 => 1.3 ===
--- Packages/pypes/pypes/tests/test_query.py:1.2 Fri Apr 2 22:50:24 2004
+++ Packages/pypes/pypes/tests/test_query.py Sun Apr 4 00:27:10 2004
@@ -229,6 +229,34 @@
for r, l in join:
self.assertEqual(l.big, r.big)
+ def test_greater_join(self):
+ from pypes.query import greater_join
+ us = [TestClass(age=14-i) for i in range(10)]
+ them = [TestClass(age=i) for i in range(15)]
+ expr = lambda x: x.age
+ joined = list(greater_join(us, expr, them, expr))
+ left2right = {}
+ for left, right in joined:
+ self.failUnless(left.age > right.age)
+ left2right.setdefault(left, []).append(right)
+ for left, lesser in left2right.items():
+ self.assertEqual(len(lesser), left.age)
+
+ def test_greater_join_empty(self):
+ from pypes.query import greater_join
+ joined = greater_join([], lambda x:x, [], lambda x:x)
+ self.failIf(list(joined))
+ objs = [TestClass() for i in range(5)]
+ joined = greater_join(objs, lambda x:x, [], lambda x:x)
+ self.failIf(list(joined))
+ joined = greater_join([], lambda x:x, objs, lambda x:x)
+ self.failIf(list(joined))
+
+ def test_greater_join_none_greater(self):
+ from pypes.query import greater_join
+ objs = [TestClass() for i in range(5)]
+ joined = greater_join(objs, lambda x: 1, objs, lambda x: 2)
+ self.failIf(list(joined))
if __name__ == '__main__':
unittest.main()
More information about the Zope-CVS
mailing list