Code

clear the cache on commit for rdbms backends: Don't carry over cached
[roundup.git] / test / test_postgresql.py
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
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 postgresqlSchemaTest(postgresqlOpener, SchemaTest):
72     def setUp(self):
73         postgresqlOpener.setUp(self)
74         SchemaTest.setUp(self)
76     def tearDown(self):
77         SchemaTest.tearDown(self)
78         postgresqlOpener.tearDown(self)
80 class postgresqlClassicInitTest(postgresqlOpener, ClassicInitTest):
81     backend = 'postgresql'
82     def setUp(self):
83         postgresqlOpener.setUp(self)
84         ClassicInitTest.setUp(self)
86     def tearDown(self):
87         ClassicInitTest.tearDown(self)
88         postgresqlOpener.tearDown(self)
90 from session_common import RDBMSTest
91 class postgresqlSessionTest(postgresqlOpener, RDBMSTest):
92     def setUp(self):
93         postgresqlOpener.setUp(self)
94         RDBMSTest.setUp(self)
95     def tearDown(self):
96         RDBMSTest.tearDown(self)
97         postgresqlOpener.tearDown(self)
99 def test_suite():
100     suite = unittest.TestSuite()
101     if not have_backend('postgresql'):
102         print "Skipping postgresql tests"
103         return suite
105     # make sure we start with a clean slate
106     if postgresqlOpener.module.db_exists(config):
107         postgresqlOpener.module.db_nuke(config, 1)
109     # TODO: Check if we can run postgresql tests
110     print 'Including postgresql tests'
111     suite.addTest(unittest.makeSuite(postgresqlDBTest))
112     suite.addTest(unittest.makeSuite(postgresqlROTest))
113     suite.addTest(unittest.makeSuite(postgresqlSchemaTest))
114     suite.addTest(unittest.makeSuite(postgresqlClassicInitTest))
115     suite.addTest(unittest.makeSuite(postgresqlSessionTest))
116     suite.addTest(unittest.makeSuite(postgresqlConcurrencyTest))
117     return suite
119 # vim: set et sts=4 sw=4 :