Mercurial > p > roundup > code
comparison test/test_db.py @ 1174:8e318dfaf479
Verify contents of tracker module when the tracker is opened
Performance improvements in *dbm and sq backends
New benchmark module. To use:
PYTHONPATH=. python2 test/benchmark.py
(yes, it's a little basic at present ;)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 20 Sep 2002 01:20:32 +0000 |
| parents | af104fa52746 |
| children | bd3b57859c37 |
comparison
equal
deleted
inserted
replaced
| 1173:58f1a2c174ed | 1174:8e318dfaf479 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: test_db.py,v 1.50 2002-09-19 02:37:41 richard Exp $ | 18 # $Id: test_db.py,v 1.51 2002-09-20 01:20:32 richard Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil, time | 20 import unittest, os, shutil, time |
| 21 | 21 |
| 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ | 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ |
| 23 Interval, DatabaseError, Boolean, Number | 23 Interval, DatabaseError, Boolean, Number |
| 155 self.db.user.set('1', age=3) | 155 self.db.user.set('1', age=3) |
| 156 self.assertNotEqual(self.db.user.get('1', 'age'), 1) | 156 self.assertNotEqual(self.db.user.get('1', 'age'), 1) |
| 157 self.db.user.set('1', age=1.0) | 157 self.db.user.set('1', age=1.0) |
| 158 self.db.user.set('1', age=None) | 158 self.db.user.set('1', age=None) |
| 159 self.assertEqual(self.db.user.get('1', "age"), None) | 159 self.assertEqual(self.db.user.get('1', "age"), None) |
| 160 | |
| 161 def testKeyValue(self): | |
| 162 newid = self.db.user.create(username="spam") | |
| 163 self.assertEqual(self.db.user.lookup('spam'), newid) | |
| 164 self.db.commit() | |
| 165 self.assertEqual(self.db.user.lookup('spam'), newid) | |
| 166 self.db.user.retire(newid) | |
| 167 self.assertRaises(KeyError, self.db.user.lookup, 'spam') | |
| 160 | 168 |
| 161 def testNewProperty(self): | 169 def testNewProperty(self): |
| 162 self.db.issue.create(title="spam", status='1') | 170 self.db.issue.create(title="spam", status='1') |
| 163 self.db.issue.addprop(fixer=Link("user")) | 171 self.db.issue.addprop(fixer=Link("user")) |
| 164 # force any post-init stuff to happen | 172 # force any post-init stuff to happen |
| 710 def suite(): | 718 def suite(): |
| 711 l = [ | 719 l = [ |
| 712 unittest.makeSuite(anydbmDBTestCase, 'test'), | 720 unittest.makeSuite(anydbmDBTestCase, 'test'), |
| 713 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') | 721 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') |
| 714 ] | 722 ] |
| 715 #return unittest.TestSuite(l) | 723 # return unittest.TestSuite(l) |
| 716 | 724 |
| 717 try: | 725 try: |
| 718 import sqlite | 726 import sqlite |
| 719 l.append(unittest.makeSuite(sqliteDBTestCase, 'test')) | 727 l.append(unittest.makeSuite(sqliteDBTestCase, 'test')) |
| 720 l.append(unittest.makeSuite(sqliteReadOnlyDBTestCase, 'test')) | 728 l.append(unittest.makeSuite(sqliteReadOnlyDBTestCase, 'test')) |
| 721 except: | 729 except: |
| 722 print 'sqlite module not found, skipping gadfly DBTestCase' | 730 print 'sqlite module not found, skipping gadfly DBTestCase' |
| 731 # return unittest.TestSuite(l) | |
| 723 | 732 |
| 724 try: | 733 try: |
| 725 import gadfly | 734 import gadfly |
| 726 l.append(unittest.makeSuite(gadflyDBTestCase, 'test')) | 735 l.append(unittest.makeSuite(gadflyDBTestCase, 'test')) |
| 727 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test')) | 736 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test')) |
