Mercurial > p > roundup > code
comparison test/test_db.py @ 1170:af104fa52746
Added some words to the installation doc about choosing backends.
Added hyperdb Class.filter unit tests - gadfly currently fails
substring searching, but I knew it would :(
Lots of fixes to the RDBMS backend - it works a treat now!
A couple of other cleanups in CGI land...
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 19 Sep 2002 02:37:41 +0000 |
| parents | 94620e088e3a |
| children | 8e318dfaf479 |
comparison
equal
deleted
inserted
replaced
| 1169:7b448a2425fd | 1170:af104fa52746 |
|---|---|
| 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.49 2002-09-18 07:04:39 richard Exp $ | 18 # $Id: test_db.py,v 1.50 2002-09-19 02:37:41 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 |
| 474 self.db.post_init() | 474 self.db.post_init() |
| 475 self.db.indexer.quiet = 9 | 475 self.db.indexer.quiet = 9 |
| 476 self.assertEquals(self.db.indexer.search(['flebble'], self.db.issue), | 476 self.assertEquals(self.db.indexer.search(['flebble'], self.db.issue), |
| 477 {'1': {}}) | 477 {'1': {}}) |
| 478 | 478 |
| 479 def filteringSetup(self): | |
| 480 for user in ( | |
| 481 {'username': 'bleep'}, | |
| 482 {'username': 'blop'}, | |
| 483 {'username': 'blorp'}): | |
| 484 self.db.user.create(**user) | |
| 485 iss = self.db.issue | |
| 486 for issue in ( | |
| 487 {'title': 'issue one', 'status': '2'}, | |
| 488 {'title': 'issue two', 'status': '1'}, | |
| 489 {'title': 'issue three', 'status': '1', 'nosy': ['1','2']}): | |
| 490 self.db.issue.create(**issue) | |
| 491 self.db.commit() | |
| 492 return self.assertEqual, self.db.issue.filter | |
| 493 | |
| 494 def testFilteringString(self): | |
| 495 ae, filt = self.filteringSetup() | |
| 496 ae(filt(None, {'title': 'issue one'}, ('+','id'), (None,None)), ['1']) | |
| 497 ae(filt(None, {'title': 'issue'}, ('+','id'), (None,None)), | |
| 498 ['1','2','3']) | |
| 499 | |
| 500 def testFilteringLink(self): | |
| 501 ae, filt = self.filteringSetup() | |
| 502 ae(filt(None, {'status': '1'}, ('+','id'), (None,None)), ['2','3']) | |
| 503 | |
| 504 def testFilteringMultilink(self): | |
| 505 ae, filt = self.filteringSetup() | |
| 506 ae(filt(None, {'nosy': '2'}, ('+','id'), (None,None)), ['3']) | |
| 507 | |
| 508 def testFilteringMany(self): | |
| 509 ae, filt = self.filteringSetup() | |
| 510 ae(filt(None, {'nosy': '2', 'status': '1'}, ('+','id'), (None,None)), | |
| 511 ['3']) | |
| 512 | |
| 479 class anydbmReadOnlyDBTestCase(MyTestCase): | 513 class anydbmReadOnlyDBTestCase(MyTestCase): |
| 480 def setUp(self): | 514 def setUp(self): |
| 481 from roundup.backends import anydbm | 515 from roundup.backends import anydbm |
| 482 # remove previous test, ignore errors | 516 # remove previous test, ignore errors |
| 483 if os.path.exists(config.DATABASE): | 517 if os.path.exists(config.DATABASE): |
| 676 def suite(): | 710 def suite(): |
| 677 l = [ | 711 l = [ |
| 678 unittest.makeSuite(anydbmDBTestCase, 'test'), | 712 unittest.makeSuite(anydbmDBTestCase, 'test'), |
| 679 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') | 713 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') |
| 680 ] | 714 ] |
| 681 # return unittest.TestSuite(l) | 715 #return unittest.TestSuite(l) |
| 716 | |
| 717 try: | |
| 718 import sqlite | |
| 719 l.append(unittest.makeSuite(sqliteDBTestCase, 'test')) | |
| 720 l.append(unittest.makeSuite(sqliteReadOnlyDBTestCase, 'test')) | |
| 721 except: | |
| 722 print 'sqlite module not found, skipping gadfly DBTestCase' | |
| 723 | |
| 724 try: | |
| 725 import gadfly | |
| 726 l.append(unittest.makeSuite(gadflyDBTestCase, 'test')) | |
| 727 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test')) | |
| 728 except: | |
| 729 print 'gadfly module not found, skipping gadfly DBTestCase' | |
| 682 | 730 |
| 683 try: | 731 try: |
| 684 import bsddb | 732 import bsddb |
| 685 l.append(unittest.makeSuite(bsddbDBTestCase, 'test')) | 733 l.append(unittest.makeSuite(bsddbDBTestCase, 'test')) |
| 686 l.append(unittest.makeSuite(bsddbReadOnlyDBTestCase, 'test')) | 734 l.append(unittest.makeSuite(bsddbReadOnlyDBTestCase, 'test')) |
| 693 l.append(unittest.makeSuite(bsddb3ReadOnlyDBTestCase, 'test')) | 741 l.append(unittest.makeSuite(bsddb3ReadOnlyDBTestCase, 'test')) |
| 694 except: | 742 except: |
| 695 print 'bsddb3 module not found, skipping bsddb3 DBTestCase' | 743 print 'bsddb3 module not found, skipping bsddb3 DBTestCase' |
| 696 | 744 |
| 697 try: | 745 try: |
| 698 import gadfly | |
| 699 l.append(unittest.makeSuite(gadflyDBTestCase, 'test')) | |
| 700 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test')) | |
| 701 except: | |
| 702 print 'gadfly module not found, skipping gadfly DBTestCase' | |
| 703 | |
| 704 try: | |
| 705 import sqlite | |
| 706 l.append(unittest.makeSuite(sqliteDBTestCase, 'test')) | |
| 707 l.append(unittest.makeSuite(sqliteReadOnlyDBTestCase, 'test')) | |
| 708 except: | |
| 709 print 'sqlite module not found, skipping gadfly DBTestCase' | |
| 710 | |
| 711 try: | |
| 712 import metakit | 746 import metakit |
| 713 l.append(unittest.makeSuite(metakitDBTestCase, 'test')) | 747 l.append(unittest.makeSuite(metakitDBTestCase, 'test')) |
| 714 l.append(unittest.makeSuite(metakitReadOnlyDBTestCase, 'test')) | 748 l.append(unittest.makeSuite(metakitReadOnlyDBTestCase, 'test')) |
| 715 except: | 749 except: |
| 716 print 'metakit module not found, skipping metakit DBTestCase' | 750 print 'metakit module not found, skipping metakit DBTestCase' |
