Premiere version : mise en route du suivi.
[auf_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 $
19
20 import unittest
21
22 from roundup.hyperdb import DatabaseError
23
24 from db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest
25
26 from roundup.backends import get_backend, have_backend
27
28 class postgresqlOpener:
29 if have_backend('postgresql'):
30 module = get_backend('postgresql')
31
32 def setUp(self):
33 pass
34
35 def tearDown(self):
36 self.nuke_database()
37
38 def nuke_database(self):
39 # clear out the database - easiest way is to nuke and re-create it
40 self.module.db_nuke(config)
41
42 class postgresqlDBTest(postgresqlOpener, DBTest):
43 def setUp(self):
44 postgresqlOpener.setUp(self)
45 DBTest.setUp(self)
46
47 def tearDown(self):
48 DBTest.tearDown(self)
49 postgresqlOpener.tearDown(self)
50
51 class postgresqlROTest(postgresqlOpener, ROTest):
52 def setUp(self):
53 postgresqlOpener.setUp(self)
54 ROTest.setUp(self)
55
56 def tearDown(self):
57 ROTest.tearDown(self)
58 postgresqlOpener.tearDown(self)
59
60 class postgresqlSchemaTest(postgresqlOpener, SchemaTest):
61 def setUp(self):
62 postgresqlOpener.setUp(self)
63 SchemaTest.setUp(self)
64
65 def tearDown(self):
66 SchemaTest.tearDown(self)
67 postgresqlOpener.tearDown(self)
68
69 class postgresqlClassicInitTest(postgresqlOpener, ClassicInitTest):
70 backend = 'postgresql'
71 def setUp(self):
72 postgresqlOpener.setUp(self)
73 ClassicInitTest.setUp(self)
74
75 def tearDown(self):
76 ClassicInitTest.tearDown(self)
77 postgresqlOpener.tearDown(self)
78
79 from session_common import RDBMSTest
80 class postgresqlSessionTest(postgresqlOpener, RDBMSTest):
81 def setUp(self):
82 postgresqlOpener.setUp(self)
83 RDBMSTest.setUp(self)
84 def tearDown(self):
85 RDBMSTest.tearDown(self)
86 postgresqlOpener.tearDown(self)
87
88 def test_suite():
89 suite = unittest.TestSuite()
90 if not have_backend('postgresql'):
91 print "Skipping postgresql tests"
92 return suite
93
94 # make sure we start with a clean slate
95 if postgresqlOpener.module.db_exists(config):
96 postgresqlOpener.module.db_nuke(config, 1)
97
98 # TODO: Check if we can run postgresql tests
99 print 'Including postgresql tests'
100 suite.addTest(unittest.makeSuite(postgresqlDBTest))
101 suite.addTest(unittest.makeSuite(postgresqlROTest))
102 suite.addTest(unittest.makeSuite(postgresqlSchemaTest))
103 suite.addTest(unittest.makeSuite(postgresqlClassicInitTest))
104 suite.addTest(unittest.makeSuite(postgresqlSessionTest))
105 return suite
106
107 # vim: set et sts=4 sw=4 :