Mercurial > p > roundup > code
comparison test/test_postgresql.py @ 2856:adec352e2ce0
don't try to import all backends in backends.__init__ unless we *want* to
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 03 Nov 2004 01:34:21 +0000 |
| parents | 93c58a68061b |
| children | 4d9adb8bc3b1 |
comparison
equal
deleted
inserted
replaced
| 2855:874bf6abad42 | 2856:adec352e2ce0 |
|---|---|
| 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.11 2004-09-25 15:50:36 a1s Exp $ | 18 # $Id: test_postgresql.py,v 1.12 2004-11-03 01:34:21 richard Exp $ |
| 19 | 19 |
| 20 import unittest | 20 import unittest |
| 21 | 21 |
| 22 from roundup.hyperdb import DatabaseError | 22 from roundup.hyperdb import DatabaseError |
| 23 | 23 |
| 24 from db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest | 24 from db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest |
| 25 | 25 |
| 26 from roundup import backends | 26 from roundup.backends import get_backend, have_backend |
| 27 | 27 |
| 28 class postgresqlOpener: | 28 class postgresqlOpener: |
| 29 if hasattr(backends, 'postgresql'): | 29 if have_backend('postgresql'): |
| 30 from roundup.backends import postgresql as module | 30 module = get_backend('postgresql') |
| 31 | 31 |
| 32 def setUp(self): | 32 def setUp(self): |
| 33 #from roundup.backends.back_postgresql import db_nuke | |
| 34 #db_nuke(config, 1) | |
| 35 pass | 33 pass |
| 36 | 34 |
| 37 def tearDown(self): | 35 def tearDown(self): |
| 38 self.nuke_database() | 36 self.nuke_database() |
| 39 | 37 |
| 40 def nuke_database(self): | 38 def nuke_database(self): |
| 41 # clear out the database - easiest way is to nuke and re-create it | 39 # clear out the database - easiest way is to nuke and re-create it |
| 42 from roundup.backends.back_postgresql import db_nuke | 40 self.module.db_nuke(config) |
| 43 db_nuke(config) | |
| 44 | 41 |
| 45 class postgresqlDBTest(postgresqlOpener, DBTest): | 42 class postgresqlDBTest(postgresqlOpener, DBTest): |
| 46 def setUp(self): | 43 def setUp(self): |
| 47 postgresqlOpener.setUp(self) | 44 postgresqlOpener.setUp(self) |
| 48 DBTest.setUp(self) | 45 DBTest.setUp(self) |
| 97 RDBMSTest.tearDown(self) | 94 RDBMSTest.tearDown(self) |
| 98 postgresqlOpener.tearDown(self) | 95 postgresqlOpener.tearDown(self) |
| 99 | 96 |
| 100 def test_suite(): | 97 def test_suite(): |
| 101 suite = unittest.TestSuite() | 98 suite = unittest.TestSuite() |
| 102 if not hasattr(backends, 'postgresql'): | 99 if not have_backend('postgresql'): |
| 103 print "Skipping postgresql tests" | 100 print "Skipping postgresql tests" |
| 104 return suite | 101 return suite |
| 105 | 102 |
| 106 # make sure we start with a clean slate | 103 # make sure we start with a clean slate |
| 107 from roundup.backends.back_postgresql import db_nuke, db_exists | 104 if postgresqlOpener.module.db_exists(config): |
| 108 if db_exists(config): | 105 postgresqlOpener.module.db_nuke(config, 1) |
| 109 db_nuke(config, 1) | |
| 110 | 106 |
| 111 # TODO: Check if we can run postgresql tests | 107 # TODO: Check if we can run postgresql tests |
| 112 print 'Including postgresql tests' | 108 print 'Including postgresql tests' |
| 113 suite.addTest(unittest.makeSuite(postgresqlDBTest)) | 109 suite.addTest(unittest.makeSuite(postgresqlDBTest)) |
| 114 suite.addTest(unittest.makeSuite(postgresqlROTest)) | 110 suite.addTest(unittest.makeSuite(postgresqlROTest)) |
