Mercurial > p > roundup > code
comparison test/test_db.py @ 1378:5d1fe5d51c12
note on how to fix mysql tests - also indicate which tests are being run
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 14 Jan 2003 10:52:05 +0000 |
| parents | faf93d3fbf2f |
| children | 083cce7840aa |
comparison
equal
deleted
inserted
replaced
| 1377:9ddb3ab23a3f | 1378:5d1fe5d51c12 |
|---|---|
| 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.66 2003-01-13 23:32:12 richard Exp $ | 18 # $Id: test_db.py,v 1.67 2003-01-14 10:52:05 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 |
| 202 self.assertEqual(self.db.user.lookup('spam'), newid) | 202 self.assertEqual(self.db.user.lookup('spam'), newid) |
| 203 self.db.commit() | 203 self.db.commit() |
| 204 self.assertEqual(self.db.user.lookup('spam'), newid) | 204 self.assertEqual(self.db.user.lookup('spam'), newid) |
| 205 self.db.user.retire(newid) | 205 self.db.user.retire(newid) |
| 206 self.assertRaises(KeyError, self.db.user.lookup, 'spam') | 206 self.assertRaises(KeyError, self.db.user.lookup, 'spam') |
| 207 | |
| 208 # use the key again now that the old is retired | |
| 209 newid2 = self.db.user.create(username="spam") | |
| 210 self.assertNotEqual(newid, newid2) | |
| 207 | 211 |
| 208 def testNewProperty(self): | 212 def testNewProperty(self): |
| 209 self.db.issue.create(title="spam", status='1') | 213 self.db.issue.create(title="spam", status='1') |
| 210 self.db.issue.addprop(fixer=Link("user")) | 214 self.db.issue.addprop(fixer=Link("user")) |
| 211 # force any post-init stuff to happen | 215 # force any post-init stuff to happen |
| 700 db.close() | 704 db.close() |
| 701 self.db = gadfly.Database(config) | 705 self.db = gadfly.Database(config) |
| 702 setupSchema(self.db, 0, gadfly) | 706 setupSchema(self.db, 0, gadfly) |
| 703 | 707 |
| 704 | 708 |
| 709 # XXX to fix the mysql tests... | |
| 710 # From: Andrey Lebedev <andrey@micro.lt> | |
| 711 # I believe we can DROP DATABASE <dbname> and then CREATE DATABASE | |
| 712 # <dbname>.. it's an easiest way. This will work if db user has all | |
| 713 # privileges on database. | |
| 714 # Another way - to perform "SHOW TABLES" SQL and then perform DROP TABLE | |
| 715 # <tblname> on each table... | |
| 705 class mysqlDBTestCase(anydbmDBTestCase): | 716 class mysqlDBTestCase(anydbmDBTestCase): |
| 706 def setUp(self): | 717 def setUp(self): |
| 707 from roundup.backends import mysql | 718 from roundup.backends import mysql |
| 708 # remove previous test, ignore errors | 719 # remove previous test, ignore errors |
| 709 if os.path.exists(config.DATABASE): | 720 if os.path.exists(config.DATABASE): |
| 818 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') | 829 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') |
| 819 ] | 830 ] |
| 820 # return unittest.TestSuite(l) | 831 # return unittest.TestSuite(l) |
| 821 | 832 |
| 822 from roundup import backends | 833 from roundup import backends |
| 823 if hasattr(backends, 'mysql'): | 834 p = [] |
| 824 l.append(unittest.makeSuite(mysqlDBTestCase, 'test')) | 835 # if hasattr(backends, 'mysql'): |
| 825 l.append(unittest.makeSuite(mysqlReadOnlyDBTestCase, 'test')) | 836 # p.append('mysql') |
| 837 # l.append(unittest.makeSuite(mysqlDBTestCase, 'test')) | |
| 838 # l.append(unittest.makeSuite(mysqlReadOnlyDBTestCase, 'test')) | |
| 826 # return unittest.TestSuite(l) | 839 # return unittest.TestSuite(l) |
| 827 | 840 |
| 828 if hasattr(backends, 'gadfly'): | 841 if hasattr(backends, 'gadfly'): |
| 842 p.append('gadfly') | |
| 829 l.append(unittest.makeSuite(gadflyDBTestCase, 'test')) | 843 l.append(unittest.makeSuite(gadflyDBTestCase, 'test')) |
| 830 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test')) | 844 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test')) |
| 831 | 845 |
| 832 if hasattr(backends, 'sqlite'): | 846 if hasattr(backends, 'sqlite'): |
| 847 p.append('sqlite') | |
| 833 l.append(unittest.makeSuite(sqliteDBTestCase, 'test')) | 848 l.append(unittest.makeSuite(sqliteDBTestCase, 'test')) |
| 834 l.append(unittest.makeSuite(sqliteReadOnlyDBTestCase, 'test')) | 849 l.append(unittest.makeSuite(sqliteReadOnlyDBTestCase, 'test')) |
| 835 | 850 |
| 836 if hasattr(backends, 'bsddb'): | 851 if hasattr(backends, 'bsddb'): |
| 852 p.append('bsddb') | |
| 837 l.append(unittest.makeSuite(bsddbDBTestCase, 'test')) | 853 l.append(unittest.makeSuite(bsddbDBTestCase, 'test')) |
| 838 l.append(unittest.makeSuite(bsddbReadOnlyDBTestCase, 'test')) | 854 l.append(unittest.makeSuite(bsddbReadOnlyDBTestCase, 'test')) |
| 839 | 855 |
| 840 if hasattr(backends, 'bsddb3'): | 856 if hasattr(backends, 'bsddb3'): |
| 857 p.append('bsddb3') | |
| 841 l.append(unittest.makeSuite(bsddb3DBTestCase, 'test')) | 858 l.append(unittest.makeSuite(bsddb3DBTestCase, 'test')) |
| 842 l.append(unittest.makeSuite(bsddb3ReadOnlyDBTestCase, 'test')) | 859 l.append(unittest.makeSuite(bsddb3ReadOnlyDBTestCase, 'test')) |
| 843 | 860 |
| 844 if hasattr(backends, 'metakit'): | 861 if hasattr(backends, 'metakit'): |
| 862 p.append('metakit') | |
| 845 l.append(unittest.makeSuite(metakitDBTestCase, 'test')) | 863 l.append(unittest.makeSuite(metakitDBTestCase, 'test')) |
| 846 l.append(unittest.makeSuite(metakitReadOnlyDBTestCase, 'test')) | 864 l.append(unittest.makeSuite(metakitReadOnlyDBTestCase, 'test')) |
| 847 | 865 |
| 866 print 'running %s backend tests'%(', '.join(p)) | |
| 848 return unittest.TestSuite(l) | 867 return unittest.TestSuite(l) |
| 849 | 868 |
| 850 # vim: set filetype=python ts=4 sw=4 et si | 869 # vim: set filetype=python ts=4 sw=4 et si |
