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.13 2006-08-23 12:57:10 schlatterbeck Exp $
20 import unittest
22 from roundup.hyperdb import DatabaseError
24 from db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest
25 from db_test_base import ConcurrentDBTest, FilterCacheTest
27 from roundup.backends import get_backend, have_backend
29 class postgresqlOpener:
30 if have_backend('postgresql'):
31 module = get_backend('postgresql')
33 def setUp(self):
34 pass
36 def tearDown(self):
37 self.nuke_database()
39 def nuke_database(self):
40 # clear out the database - easiest way is to nuke and re-create it
41 self.module.db_nuke(config)
43 class postgresqlDBTest(postgresqlOpener, DBTest):
44 def setUp(self):
45 postgresqlOpener.setUp(self)
46 DBTest.setUp(self)
48 def tearDown(self):
49 DBTest.tearDown(self)
50 postgresqlOpener.tearDown(self)
52 class postgresqlROTest(postgresqlOpener, ROTest):
53 def setUp(self):
54 postgresqlOpener.setUp(self)
55 ROTest.setUp(self)
57 def tearDown(self):
58 ROTest.tearDown(self)
59 postgresqlOpener.tearDown(self)
61 class postgresqlConcurrencyTest(postgresqlOpener, ConcurrentDBTest):
62 backend = 'postgresql'
63 def setUp(self):
64 postgresqlOpener.setUp(self)
65 ConcurrentDBTest.setUp(self)
67 def tearDown(self):
68 ConcurrentDBTest.tearDown(self)
69 postgresqlOpener.tearDown(self)
71 class postgresqlFilterCacheTest(postgresqlOpener, FilterCacheTest):
72 backend = 'postgresql'
73 def setUp(self):
74 postgresqlOpener.setUp(self)
75 FilterCacheTest.setUp(self)
77 def tearDown(self):
78 FilterCacheTest.tearDown(self)
79 postgresqlOpener.tearDown(self)
81 class postgresqlSchemaTest(postgresqlOpener, SchemaTest):
82 def setUp(self):
83 postgresqlOpener.setUp(self)
84 SchemaTest.setUp(self)
86 def tearDown(self):
87 SchemaTest.tearDown(self)
88 postgresqlOpener.tearDown(self)
90 class postgresqlClassicInitTest(postgresqlOpener, ClassicInitTest):
91 backend = 'postgresql'
92 def setUp(self):
93 postgresqlOpener.setUp(self)
94 ClassicInitTest.setUp(self)
96 def tearDown(self):
97 ClassicInitTest.tearDown(self)
98 postgresqlOpener.tearDown(self)
100 from session_common import RDBMSTest
101 class postgresqlSessionTest(postgresqlOpener, RDBMSTest):
102 def setUp(self):
103 postgresqlOpener.setUp(self)
104 RDBMSTest.setUp(self)
105 def tearDown(self):
106 RDBMSTest.tearDown(self)
107 postgresqlOpener.tearDown(self)
109 def test_suite():
110 suite = unittest.TestSuite()
111 if not have_backend('postgresql'):
112 print "Skipping postgresql tests"
113 return suite
115 # make sure we start with a clean slate
116 if postgresqlOpener.module.db_exists(config):
117 postgresqlOpener.module.db_nuke(config, 1)
119 # TODO: Check if we can run postgresql tests
120 print 'Including postgresql tests'
121 suite.addTest(unittest.makeSuite(postgresqlDBTest))
122 suite.addTest(unittest.makeSuite(postgresqlROTest))
123 suite.addTest(unittest.makeSuite(postgresqlSchemaTest))
124 suite.addTest(unittest.makeSuite(postgresqlClassicInitTest))
125 suite.addTest(unittest.makeSuite(postgresqlSessionTest))
126 suite.addTest(unittest.makeSuite(postgresqlConcurrencyTest))
127 suite.addTest(unittest.makeSuite(postgresqlFilterCacheTest))
128 return suite
130 # vim: set et sts=4 sw=4 :