Mercurial > p > roundup > code
comparison test/test_db.py @ 1415:6883852e9b15
mysql backend passes all tests (at last!)
| author | Andrey Lebedev <kedder@users.sourceforge.net> |
|---|---|
| date | Sat, 08 Feb 2003 15:31:28 +0000 |
| parents | 083cce7840aa |
| children | 8429095241d7 |
comparison
equal
deleted
inserted
replaced
| 1414:b4630d078c08 | 1415:6883852e9b15 |
|---|---|
| 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.68 2003-01-20 23:03:41 richard Exp $ | 18 # $Id: test_db.py,v 1.69 2003-02-08 15:31:28 kedder 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 |
| 730 if os.path.exists(config.DATABASE): | 730 if os.path.exists(config.DATABASE): |
| 731 shutil.rmtree(config.DATABASE) | 731 shutil.rmtree(config.DATABASE) |
| 732 config.MYSQL_DATABASE = ('localhost', 'rounduptest', 'rounduptest', | 732 config.MYSQL_DATABASE = ('localhost', 'rounduptest', 'rounduptest', |
| 733 'rounduptest') | 733 'rounduptest') |
| 734 os.makedirs(config.DATABASE + '/files') | 734 os.makedirs(config.DATABASE + '/files') |
| 735 # open database for cleaning | |
| 735 self.db = mysql.Database(config, 'admin') | 736 self.db = mysql.Database(config, 'admin') |
| 737 self.db.sql("DROP DATABASE %s" % config.MYSQL_DATABASE[1]) | |
| 738 self.db.sql("CREATE DATABASE %s" % config.MYSQL_DATABASE[1]) | |
| 739 self.db.close() | |
| 740 # open database for testing | |
| 741 self.db = mysql.Database(config, 'admin') | |
| 742 | |
| 736 setupSchema(self.db, 1, mysql) | 743 setupSchema(self.db, 1, mysql) |
| 737 | 744 |
| 738 class mysqlReadOnlyDBTestCase(anydbmReadOnlyDBTestCase): | 745 class mysqlReadOnlyDBTestCase(anydbmReadOnlyDBTestCase): |
| 739 def setUp(self): | 746 def setUp(self): |
| 740 from roundup.backends import mysql | 747 from roundup.backends import mysql |
| 742 if os.path.exists(config.DATABASE): | 749 if os.path.exists(config.DATABASE): |
| 743 shutil.rmtree(config.DATABASE) | 750 shutil.rmtree(config.DATABASE) |
| 744 config.MYSQL_DATABASE = ('localhost', 'rounduptest', 'rounduptest', | 751 config.MYSQL_DATABASE = ('localhost', 'rounduptest', 'rounduptest', |
| 745 'rounduptest') | 752 'rounduptest') |
| 746 os.makedirs(config.DATABASE + '/files') | 753 os.makedirs(config.DATABASE + '/files') |
| 747 db = mysql.Database(config, 'admin') | 754 # open database for cleaning |
| 748 setupSchema(db, 1, mysql) | 755 self.db = mysql.Database(config, 'admin') |
| 749 db.close() | 756 self.db.sql("DROP DATABASE %s" % config.MYSQL_DATABASE[1]) |
| 750 self.db = sqlite.Database(config) | 757 self.db.sql("CREATE DATABASE %s" % config.MYSQL_DATABASE[1]) |
| 758 self.db.close() | |
| 759 # open database for testing | |
| 760 self.db = mysql.Database(config) | |
| 751 setupSchema(self.db, 0, mysql) | 761 setupSchema(self.db, 0, mysql) |
| 752 | |
| 753 | 762 |
| 754 class sqliteDBTestCase(anydbmDBTestCase): | 763 class sqliteDBTestCase(anydbmDBTestCase): |
| 755 def setUp(self): | 764 def setUp(self): |
| 756 from roundup.backends import sqlite | 765 from roundup.backends import sqlite |
| 757 # remove previous test, ignore errors | 766 # remove previous test, ignore errors |
| 844 db.close() | 853 db.close() |
| 845 self.db = metakit.Database(config) | 854 self.db = metakit.Database(config) |
| 846 setupSchema(self.db, 0, metakit) | 855 setupSchema(self.db, 0, metakit) |
| 847 | 856 |
| 848 def suite(): | 857 def suite(): |
| 849 l = [ | 858 l = [] |
| 850 unittest.makeSuite(anydbmDBTestCase, 'test'), | 859 # l = [ |
| 851 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') | 860 # unittest.makeSuite(anydbmDBTestCase, 'test'), |
| 852 ] | 861 # unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') |
| 862 # ] | |
| 853 # return unittest.TestSuite(l) | 863 # return unittest.TestSuite(l) |
| 854 | 864 |
| 855 from roundup import backends | 865 from roundup import backends |
| 856 p = [] | 866 p = [] |
| 857 # if hasattr(backends, 'mysql'): | 867 if hasattr(backends, 'mysql'): |
| 858 # p.append('mysql') | 868 p.append('mysql') |
| 859 # l.append(unittest.makeSuite(mysqlDBTestCase, 'test')) | 869 l.append(unittest.makeSuite(mysqlDBTestCase, 'test')) |
| 860 # l.append(unittest.makeSuite(mysqlReadOnlyDBTestCase, 'test')) | 870 l.append(unittest.makeSuite(mysqlReadOnlyDBTestCase, 'test')) |
| 861 # return unittest.TestSuite(l) | 871 #return unittest.TestSuite(l) |
| 862 | 872 |
| 863 if hasattr(backends, 'gadfly'): | 873 if hasattr(backends, 'gadfly'): |
| 864 p.append('gadfly') | 874 p.append('gadfly') |
| 865 l.append(unittest.makeSuite(gadflyDBTestCase, 'test')) | 875 l.append(unittest.makeSuite(gadflyDBTestCase, 'test')) |
| 866 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test')) | 876 l.append(unittest.makeSuite(gadflyReadOnlyDBTestCase, 'test')) |
