comparison test/test_postgresql.py @ 1873:f63aa57386b0

Backend improvements. - using Zope3's test runner now, allowing GC checks, nicer controls and coverage analysis - all RDMBS backends now have indexes on several columns - added testing of schema mutation, fixed rdbms backends handling of a couple of cases - !BETA! added postgresql backend, needs work !BETA!
author Richard Jones <richard@users.sourceforge.net>
date Sat, 25 Oct 2003 22:53:26 +0000
parents
children 13b95c9936fc
comparison
equal deleted inserted replaced
1872:c085b4f4f0c0 1873:f63aa57386b0
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
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"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 #
18 # $Id: test_postgresql.py,v 1.1 2003-10-25 22:53:26 richard Exp $
19
20 import unittest, os, shutil, time
21
22 from roundup.hyperdb import DatabaseError
23
24 from db_test_base import DBTest, ROTest, config, SchemaTest, nodbconfig, \
25 ClassicInitTest
26
27 from roundup import backends
28
29 class postgresqlOpener:
30 if hasattr(backends, 'metakit'):
31 from roundup.backends import postgresql as module
32
33 def tearDown(self):
34 self.db.close()
35 self.module.Database.nuke(config)
36
37 class postgresqlDBTest(postgresqlOpener, DBTest):
38 pass
39
40 class postgresqlROTest(postgresqlOpener, ROTest):
41 pass
42
43 class postgresqlSchemaTest(postgresqlOpener, SchemaTest):
44 pass
45
46 class postgresqlClassicInitTest(ClassicInitTest):
47 backend = 'postgresql'
48
49 def test_suite():
50 suite = unittest.TestSuite()
51 if not hasattr(backends, 'postgresql'):
52 return suite
53
54 from roundup.backends import postgresql
55 try:
56 # Check if we can run postgresql tests
57 import psycopg
58 db = psycopg.Database(nodbconfig, 'admin')
59 db.conn.select_db(config.POSTGRESQL_DBNAME)
60 db.sql("SHOW TABLES");
61 tables = db.sql_fetchall()
62 if tables:
63 # Database should be empty. We don't dare to delete any data
64 raise DatabaseError, "(Database %s contains tables)"%\
65 config.POSTGRESQL_DBNAME
66 db.sql("DROP DATABASE %s" % config.POSTGRESQL_DBNAME)
67 db.sql("CREATE DATABASE %s" % config.POSTGRESQL_DBNAME)
68 db.close()
69 except (MySQLdb.ProgrammingError, DatabaseError), msg:
70 print "Skipping postgresql tests (%s)"%msg
71 else:
72 print 'Including postgresql tests'
73 suite.addTest(unittest.makeSuite(postgresqlDBTest))
74 suite.addTest(unittest.makeSuite(postgresqlROTest))
75 suite.addTest(unittest.makeSuite(postgresqlSchemaTest))
76 suite.addTest(unittest.makeSuite(postgresqlClassicInitTest))
77 return suite
78

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