Mercurial > p > roundup > code
comparison test/test_db.py @ 1434:b953750bdc04
trackers on mysql can be initialised
added mechanism for backends to detect and clear database
| author | Andrey Lebedev <kedder@users.sourceforge.net> |
|---|---|
| date | Sat, 15 Feb 2003 23:19:01 +0000 |
| parents | 8429095241d7 |
| children | 405e91b5be46 |
comparison
equal
deleted
inserted
replaced
| 1433:8429095241d7 | 1434:b953750bdc04 |
|---|---|
| 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.70 2003-02-15 14:26:38 kedder Exp $ | 18 # $Id: test_db.py,v 1.71 2003-02-15 23:19:01 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 |
| 736 setupSchema(self.db, 1, mysql) | 736 setupSchema(self.db, 1, mysql) |
| 737 | 737 |
| 738 def tearDown(self): | 738 def tearDown(self): |
| 739 from roundup.backends import mysql | 739 from roundup.backends import mysql |
| 740 self.db.close() | 740 self.db.close() |
| 741 mysql.nuke(config) | 741 mysql.Database.nuke(config) |
| 742 anydbmDBTestCase.tearDown(self) | |
| 743 | 742 |
| 744 class mysqlReadOnlyDBTestCase(anydbmReadOnlyDBTestCase): | 743 class mysqlReadOnlyDBTestCase(anydbmReadOnlyDBTestCase): |
| 745 def setUp(self): | 744 def setUp(self): |
| 746 from roundup.backends import mysql | 745 from roundup.backends import mysql |
| 747 # remove previous test, ignore errors | 746 # remove previous test, ignore errors |
| 752 setupSchema(self.db, 0, mysql) | 751 setupSchema(self.db, 0, mysql) |
| 753 | 752 |
| 754 def tearDown(self): | 753 def tearDown(self): |
| 755 from roundup.backends import mysql | 754 from roundup.backends import mysql |
| 756 self.db.close() | 755 self.db.close() |
| 757 mysql.nuke(config) | 756 mysql.Database.nuke(config) |
| 758 anydbmReadOnlyDBTestCase.tearDown(self) | |
| 759 | 757 |
| 760 class sqliteDBTestCase(anydbmDBTestCase): | 758 class sqliteDBTestCase(anydbmDBTestCase): |
| 761 def setUp(self): | 759 def setUp(self): |
| 762 from roundup.backends import sqlite | 760 from roundup.backends import sqlite |
| 763 # remove previous test, ignore errors | 761 # remove previous test, ignore errors |
| 871 db.sql("SHOW TABLES"); | 869 db.sql("SHOW TABLES"); |
| 872 tables = db.sql_fetchall() | 870 tables = db.sql_fetchall() |
| 873 if tables: | 871 if tables: |
| 874 # Database should be empty. We don't dare to delete any data | 872 # Database should be empty. We don't dare to delete any data |
| 875 raise DatabaseError, "(Database %s contains tables)" % config.MYSQL_DBNAME | 873 raise DatabaseError, "(Database %s contains tables)" % config.MYSQL_DBNAME |
| 876 db.sql("DROP DATABASE IF EXISTS %s" % config.MYSQL_DBNAME) | 874 db.sql("DROP DATABASE %s" % config.MYSQL_DBNAME) |
| 877 db.sql("CREATE DATABASE %s" % config.MYSQL_DBNAME) | 875 db.sql("CREATE DATABASE %s" % config.MYSQL_DBNAME) |
| 878 db.close() | 876 db.close() |
| 879 except (MySQLdb.ProgrammingError, DatabaseError), msg: | 877 except (MySQLdb.ProgrammingError, DatabaseError), msg: |
| 880 print "Warning! Mysql tests will not be performed", msg | 878 print "Warning! Mysql tests will not be performed", msg |
| 881 print "See doc/mysql.txt for more details." | 879 print "See doc/mysql.txt for more details." |
