Skip to content

Commit

Permalink
merged in contributions to TDB tests by Brent Pedersen
Browse files Browse the repository at this point in the history
  • Loading branch information
rsms committed Mar 14, 2009
1 parent 8a0cc39 commit dcbeff4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/tc/test/__init__.py
Expand Up @@ -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):
Expand Down
30 changes: 30 additions & 0 deletions lib/tc/test/tdb.py
Expand Up @@ -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():
Expand Down

0 comments on commit dcbeff4

Please sign in to comment.