diff --git a/lib/tc/test/__init__.py b/lib/tc/test/__init__.py index 60722cd..d7e3f7a 100644 --- a/lib/tc/test/__init__.py +++ b/lib/tc/test/__init__.py @@ -3,9 +3,10 @@ def suite(): suites = [] - import hdb, bdb + import hdb, bdb, tdb suites.append(hdb.suite()) suites.append(bdb.suite()) + suites.append(tdb.suite()) return unittest.TestSuite(suites) def test(*va, **kw): diff --git a/lib/tc/test/tdb.py b/lib/tc/test/tdb.py index d6ddbcd..fe2b7ed 100644 --- a/lib/tc/test/tdb.py +++ b/lib/tc/test/tdb.py @@ -106,6 +106,36 @@ def testAll(self): self.assertEquals(pks[0], 'torgny') self.assertEquals(pks[1], 'rosa') self.assertEquals(pks[2], 'jdoe') + + q = db.query() + q.order('age', tc.TDBQONUMDESC) + # get thos with ages < 40 + q.filter('age', tc.TDBQCNUMLE, '40') + pks = q.keys() + self.assertEquals(pks[0], 'torgny') + self.assertEquals(pks[1], 'rosa') + self.assertEquals(len(pks), 2) + + # add to the filter only those > 30 ( and < 40 from before) + q.filter('age', tc.TDBQCNUMGE, '30') + pks = q.keys() + self.assertEquals(pks[0], 'torgny') + self.assertEquals(len(pks), 1) + + # filter out those who have blue in the colors + q = db.query() + q.order('age', tc.TDBQONUMDESC) + q.filter('colors', tc.TDBQCSTRINC, 'blue') + pks = q.keys() + self.assertEquals(pks[0], 'torgny') + self.assertEquals(pks[1], 'rosa') + self.assertEquals(len(pks), 2) + + # add a filter to the existing: + q.filter('colors', tc.TDBQCSTRINC, 'pink') + pks = q.keys() + self.assertEquals(pks[0], 'rosa') + self.assertEquals(len(pks), 1) def suite():