comparison test/test_db.py @ 1365:4884fb0860f9

fixed rdbms searching by ID [SF#666615] detect corrupted index and raise semi-useful exception [SF#666767] also some mysql support (in tests)
author Richard Jones <richard@users.sourceforge.net>
date Sun, 12 Jan 2003 23:53:20 +0000
parents b94cc62090be
children faf93d3fbf2f
comparison
equal deleted inserted replaced
1364:1d1ee96e8956 1365:4884fb0860f9
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.64 2003-01-12 00:43:43 richard Exp $ 18 # $Id: test_db.py,v 1.65 2003-01-12 23:53:20 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
568 {'title': 'issue three', 'status': '1', 'nosy': ['1','2']}): 568 {'title': 'issue three', 'status': '1', 'nosy': ['1','2']}):
569 self.db.issue.create(**issue) 569 self.db.issue.create(**issue)
570 self.db.commit() 570 self.db.commit()
571 return self.assertEqual, self.db.issue.filter 571 return self.assertEqual, self.db.issue.filter
572 572
573 def testFilteringID(self):
574 ae, filt = self.filteringSetup()
575 ae(filt(None, {'id': '1'}, ('+','id'), (None,None)), ['1'])
576
573 def testFilteringString(self): 577 def testFilteringString(self):
574 ae, filt = self.filteringSetup() 578 ae, filt = self.filteringSetup()
575 ae(filt(None, {'title': 'issue one'}, ('+','id'), (None,None)), ['1']) 579 ae(filt(None, {'title': 'issue one'}, ('+','id'), (None,None)), ['1'])
576 ae(filt(None, {'title': 'issue'}, ('+','id'), (None,None)), 580 ae(filt(None, {'title': 'issue'}, ('+','id'), (None,None)),
577 ['1','2','3']) 581 ['1','2','3'])
696 db.close() 700 db.close()
697 self.db = gadfly.Database(config) 701 self.db = gadfly.Database(config)
698 setupSchema(self.db, 0, gadfly) 702 setupSchema(self.db, 0, gadfly)
699 703
700 704
705 class mysqlDBTestCase(anydbmDBTestCase):
706 def setUp(self):
707 from roundup.backends import mysql
708 # remove previous test, ignore errors
709 if os.path.exists(config.DATABASE):
710 shutil.rmtree(config.DATABASE)
711 config.MYSQL_DATABASE='mysql@localhost root rootpasswd'.split()
712 os.makedirs(config.DATABASE + '/files')
713 self.db = mysql.Database(config, 'admin')
714 setupSchema(self.db, 1, mysql)
715
716 class mysqlReadOnlyDBTestCase(anydbmReadOnlyDBTestCase):
717 def setUp(self):
718 from roundup.backends import mysql
719 # remove previous test, ignore errors
720 if os.path.exists(config.DATABASE):
721 shutil.rmtree(config.DATABASE)
722 config.MYSQL_DATABASE='mysql@localhost root rootpasswd'.split()
723 os.makedirs(config.DATABASE + '/files')
724 db = mysql.Database(config, 'admin')
725 setupSchema(db, 1, mysql)
726 db.close()
727 self.db = sqlite.Database(config)
728 setupSchema(self.db, 0, mysql)
729
730
701 class sqliteDBTestCase(anydbmDBTestCase): 731 class sqliteDBTestCase(anydbmDBTestCase):
702 def setUp(self): 732 def setUp(self):
703 from roundup.backends import sqlite 733 from roundup.backends import sqlite
704 # remove previous test, ignore errors 734 # remove previous test, ignore errors
705 if os.path.exists(config.DATABASE): 735 if os.path.exists(config.DATABASE):
706 shutil.rmtree(config.DATABASE) 736 shutil.rmtree(config.DATABASE)
707 os.makedirs(config.DATABASE + '/files') 737 os.makedirs(config.DATABASE + '/files')
708 self.db = sqlite.Database(config, 'admin') 738 self.db = sqlite.Database(config, 'admin')
709 setupSchema(self.db, 1, sqlite) 739 setupSchema(self.db, 1, sqlite)
710
711 def testIDGeneration(self):
712 pass
713 740
714 class sqliteReadOnlyDBTestCase(anydbmReadOnlyDBTestCase): 741 class sqliteReadOnlyDBTestCase(anydbmReadOnlyDBTestCase):
715 def setUp(self): 742 def setUp(self):
716 from roundup.backends import sqlite 743 from roundup.backends import sqlite
717 # remove previous test, ignore errors 744 # remove previous test, ignore errors
789 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') 816 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test')
790 ] 817 ]
791 # return unittest.TestSuite(l) 818 # return unittest.TestSuite(l)
792 819
793 from roundup import backends 820 from roundup import backends
821 # if hasattr(backends, 'mysql'):
822 # l.append(unittest.makeSuite(mysqlDBTestCase, 'test'))
823 # l.append(unittest.makeSuite(mysqlReadOnlyDBTestCase, 'test'))
824 # return unittest.TestSuite(l)
825
794 if hasattr(backends, 'gadfly'): 826 if hasattr(backends, 'gadfly'):
795 l.append(unittest.makeSuite(gadflyDBTestCase, 'test')) 827 l.append(unittest.makeSuite(gadflyDBTestCase, 'test'))
796 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test')) 828 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test'))
797 829
798 if hasattr(backends, 'sqlite'): 830 if hasattr(backends, 'sqlite'):

Roundup Issue Tracker: http://roundup-tracker.org/