comparison test/test_postgresql.py @ 1877:13b95c9936fc

Fix some attributes. Note that this causes the test to fail with an error, while it just wouldn't run before.
author Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
date Sun, 26 Oct 2003 14:43:51 +0000
parents f63aa57386b0
children f255363e6d97
comparison
equal deleted inserted replaced
1876:be9b87ad711b 1877:13b95c9936fc
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_postgresql.py,v 1.1 2003-10-25 22:53:26 richard Exp $ 18 # $Id: test_postgresql.py,v 1.2 2003-10-26 14:43:51 jlgijsbers Exp $
19 19
20 import unittest, os, shutil, time 20 import unittest, os, shutil, time
21 21
22 from roundup.hyperdb import DatabaseError 22 from roundup.hyperdb import DatabaseError
23 23
25 ClassicInitTest 25 ClassicInitTest
26 26
27 from roundup import backends 27 from roundup import backends
28 28
29 class postgresqlOpener: 29 class postgresqlOpener:
30 if hasattr(backends, 'metakit'): 30 if hasattr(backends, 'postgresql'):
31 from roundup.backends import postgresql as module 31 from roundup.backends import postgresql as module
32 32
33 def tearDown(self): 33 def tearDown(self):
34 self.db.close() 34 self.db.close()
35 self.module.Database.nuke(config) 35 self.module.Database.nuke(config)
53 53
54 from roundup.backends import postgresql 54 from roundup.backends import postgresql
55 try: 55 try:
56 # Check if we can run postgresql tests 56 # Check if we can run postgresql tests
57 import psycopg 57 import psycopg
58 db = psycopg.Database(nodbconfig, 'admin') 58 db = postgresql.Database(nodbconfig, 'admin')
59 db.conn.select_db(config.POSTGRESQL_DBNAME) 59 db.conn.select_db(config.POSTGRESQL_DBNAME)
60 db.sql("SHOW TABLES"); 60 db.sql("SHOW TABLES");
61 tables = db.sql_fetchall() 61 tables = db.sql_fetchall()
62 if tables: 62 if tables:
63 # Database should be empty. We don't dare to delete any data 63 # Database should be empty. We don't dare to delete any data
64 raise DatabaseError, "(Database %s contains tables)"%\ 64 raise DatabaseError, "(Database %s contains tables)"%\
65 config.POSTGRESQL_DBNAME 65 config.POSTGRESQL_DBNAME
66 db.sql("DROP DATABASE %s" % config.POSTGRESQL_DBNAME) 66 db.sql("DROP DATABASE %s" % config.POSTGRESQL_DBNAME)
67 db.sql("CREATE DATABASE %s" % config.POSTGRESQL_DBNAME) 67 db.sql("CREATE DATABASE %s" % config.POSTGRESQL_DBNAME)
68 db.close() 68 db.close()
69 except (MySQLdb.ProgrammingError, DatabaseError), msg: 69 except (psycopg.ProgrammingError, DatabaseError), msg:
70 print "Skipping postgresql tests (%s)"%msg 70 print "Skipping postgresql tests (%s)"%msg
71 else: 71 else:
72 print 'Including postgresql tests' 72 print 'Including postgresql tests'
73 suite.addTest(unittest.makeSuite(postgresqlDBTest)) 73 suite.addTest(unittest.makeSuite(postgresqlDBTest))
74 suite.addTest(unittest.makeSuite(postgresqlROTest)) 74 suite.addTest(unittest.makeSuite(postgresqlROTest))

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