Mercurial > p > roundup > code
comparison test/test_db.py @ 524:dce4c75bef5a
changed all config accesses...
...so they access either the instance or the config attriubute on the
db. This means that all config is obtained from instance_config
instead of the mish-mash of classes. This will make switching to a
ConfigParser setup easier too, I hope.
At a minimum, this makes migration a _little_ easier (a lot easier in the
0.5.0 switch, I hope!)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 14 Jan 2002 02:20:15 +0000 |
| parents | b579418f7ed1 |
| children | 22e0edf7da6e |
comparison
equal
deleted
inserted
replaced
| 523:32db08940334 | 524:dce4c75bef5a |
|---|---|
| 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_db.py,v 1.12 2001-12-17 03:52:48 richard Exp $ | 18 # $Id: test_db.py,v 1.13 2002-01-14 02:20:15 richard Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil | 20 import unittest, os, shutil |
| 21 | 21 |
| 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ | 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ |
| 23 Interval, Class, DatabaseError | 23 Interval, Class, DatabaseError |
| 39 | 39 |
| 40 class MyTestCase(unittest.TestCase): | 40 class MyTestCase(unittest.TestCase): |
| 41 def tearDown(self): | 41 def tearDown(self): |
| 42 if os.path.exists('_test_dir'): | 42 if os.path.exists('_test_dir'): |
| 43 shutil.rmtree('_test_dir') | 43 shutil.rmtree('_test_dir') |
| 44 | 44 |
| 45 class config: | |
| 46 DATABASE='_test_dir' | |
| 47 MAILHOST = 'localhost' | |
| 48 MAIL_DOMAIN = 'fill.me.in.' | |
| 49 INSTANCE_NAME = 'Roundup issue tracker' | |
| 50 ISSUE_TRACKER_EMAIL = 'issue_tracker@%s'%MAIL_DOMAIN | |
| 51 ISSUE_TRACKER_WEB = 'http://some.useful.url/' | |
| 52 ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN | |
| 53 FILTER_POSITION = 'bottom' # one of 'top', 'bottom', 'top and bottom' | |
| 54 ANONYMOUS_ACCESS = 'deny' # either 'deny' or 'allow' | |
| 55 ANONYMOUS_REGISTER = 'deny' # either 'deny' or 'allow' | |
| 56 MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no' | |
| 57 EMAIL_SIGNATURE_POSITION = 'bottom' | |
| 58 | |
| 45 class anydbmDBTestCase(MyTestCase): | 59 class anydbmDBTestCase(MyTestCase): |
| 46 def setUp(self): | 60 def setUp(self): |
| 47 from roundup.backends import anydbm | 61 from roundup.backends import anydbm |
| 48 # remove previous test, ignore errors | 62 # remove previous test, ignore errors |
| 49 if os.path.exists('_test_dir'): | 63 if os.path.exists(config.DATABASE): |
| 50 shutil.rmtree('_test_dir') | 64 shutil.rmtree(config.DATABASE) |
| 51 os.makedirs('_test_dir/files') | 65 os.makedirs(config.DATABASE + '/files') |
| 52 self.db = anydbm.Database('_test_dir', 'test') | 66 self.db = anydbm.Database(config, 'test') |
| 53 setupSchema(self.db, 1) | 67 setupSchema(self.db, 1) |
| 54 | 68 |
| 55 def testChanges(self): | 69 def testChanges(self): |
| 56 self.db.issue.create(title="spam", status='1') | 70 self.db.issue.create(title="spam", status='1') |
| 57 self.db.issue.create(title="eggs", status='2') | 71 self.db.issue.create(title="eggs", status='2') |
| 171 | 185 |
| 172 class anydbmReadOnlyDBTestCase(MyTestCase): | 186 class anydbmReadOnlyDBTestCase(MyTestCase): |
| 173 def setUp(self): | 187 def setUp(self): |
| 174 from roundup.backends import anydbm | 188 from roundup.backends import anydbm |
| 175 # remove previous test, ignore errors | 189 # remove previous test, ignore errors |
| 176 if os.path.exists('_test_dir'): | 190 if os.path.exists(config.DATABASE): |
| 177 shutil.rmtree('_test_dir') | 191 shutil.rmtree(config.DATABASE) |
| 178 os.makedirs('_test_dir/files') | 192 os.makedirs(config.DATABASE + '/files') |
| 179 db = anydbm.Database('_test_dir', 'test') | 193 db = anydbm.Database(config, 'test') |
| 180 setupSchema(db, 1) | 194 setupSchema(db, 1) |
| 181 self.db = anydbm.Database('_test_dir') | 195 self.db = anydbm.Database(config) |
| 182 setupSchema(self.db, 0) | 196 setupSchema(self.db, 0) |
| 183 | 197 |
| 184 def testExceptions(self): | 198 def testExceptions(self): |
| 185 # this tests the exceptions that should be raised | 199 # this tests the exceptions that should be raised |
| 186 ar = self.assertRaises | 200 ar = self.assertRaises |
| 193 | 207 |
| 194 class bsddbDBTestCase(anydbmDBTestCase): | 208 class bsddbDBTestCase(anydbmDBTestCase): |
| 195 def setUp(self): | 209 def setUp(self): |
| 196 from roundup.backends import bsddb | 210 from roundup.backends import bsddb |
| 197 # remove previous test, ignore errors | 211 # remove previous test, ignore errors |
| 198 if os.path.exists('_test_dir'): | 212 if os.path.exists(config.DATABASE): |
| 199 shutil.rmtree('_test_dir') | 213 shutil.rmtree(config.DATABASE) |
| 200 os.makedirs('_test_dir/files') | 214 os.makedirs(config.DATABASE + '/files') |
| 201 self.db = bsddb.Database('_test_dir', 'test') | 215 self.db = bsddb.Database(config, 'test') |
| 202 setupSchema(self.db, 1) | 216 setupSchema(self.db, 1) |
| 203 | 217 |
| 204 class bsddbReadOnlyDBTestCase(anydbmReadOnlyDBTestCase): | 218 class bsddbReadOnlyDBTestCase(anydbmReadOnlyDBTestCase): |
| 205 def setUp(self): | 219 def setUp(self): |
| 206 from roundup.backends import bsddb | 220 from roundup.backends import bsddb |
| 207 # remove previous test, ignore errors | 221 # remove previous test, ignore errors |
| 208 if os.path.exists('_test_dir'): | 222 if os.path.exists(config.DATABASE): |
| 209 shutil.rmtree('_test_dir') | 223 shutil.rmtree(config.DATABASE) |
| 210 os.makedirs('_test_dir/files') | 224 os.makedirs(config.DATABASE + '/files') |
| 211 db = bsddb.Database('_test_dir', 'test') | 225 db = bsddb.Database(config, 'test') |
| 212 setupSchema(db, 1) | 226 setupSchema(db, 1) |
| 213 self.db = bsddb.Database('_test_dir') | 227 self.db = bsddb.Database(config) |
| 214 setupSchema(self.db, 0) | 228 setupSchema(self.db, 0) |
| 215 | 229 |
| 216 | 230 |
| 217 class bsddb3DBTestCase(anydbmDBTestCase): | 231 class bsddb3DBTestCase(anydbmDBTestCase): |
| 218 def setUp(self): | 232 def setUp(self): |
| 219 from roundup.backends import bsddb3 | 233 from roundup.backends import bsddb3 |
| 220 # remove previous test, ignore errors | 234 # remove previous test, ignore errors |
| 221 if os.path.exists('_test_dir'): | 235 if os.path.exists(config.DATABASE): |
| 222 shutil.rmtree('_test_dir') | 236 shutil.rmtree(config.DATABASE) |
| 223 os.makedirs('_test_dir/files') | 237 os.makedirs(config.DATABASE + '/files') |
| 224 self.db = bsddb3.Database('_test_dir', 'test') | 238 self.db = bsddb3.Database(config, 'test') |
| 225 setupSchema(self.db, 1) | 239 setupSchema(self.db, 1) |
| 226 | 240 |
| 227 class bsddb3ReadOnlyDBTestCase(anydbmReadOnlyDBTestCase): | 241 class bsddb3ReadOnlyDBTestCase(anydbmReadOnlyDBTestCase): |
| 228 def setUp(self): | 242 def setUp(self): |
| 229 from roundup.backends import bsddb3 | 243 from roundup.backends import bsddb3 |
| 230 # remove previous test, ignore errors | 244 # remove previous test, ignore errors |
| 231 if os.path.exists('_test_dir'): | 245 if os.path.exists(config.DATABASE): |
| 232 shutil.rmtree('_test_dir') | 246 shutil.rmtree(config.DATABASE) |
| 233 os.makedirs('_test_dir/files') | 247 os.makedirs(config.DATABASE + '/files') |
| 234 db = bsddb3.Database('_test_dir', 'test') | 248 db = bsddb3.Database(config, 'test') |
| 235 setupSchema(db, 1) | 249 setupSchema(db, 1) |
| 236 self.db = bsddb3.Database('_test_dir') | 250 self.db = bsddb3.Database(config) |
| 237 setupSchema(self.db, 0) | 251 setupSchema(self.db, 0) |
| 238 | 252 |
| 239 | 253 |
| 240 def suite(): | 254 def suite(): |
| 241 l = [unittest.makeSuite(anydbmDBTestCase, 'test'), | 255 l = [unittest.makeSuite(anydbmDBTestCase, 'test'), |
| 258 | 272 |
| 259 return unittest.TestSuite(l) | 273 return unittest.TestSuite(l) |
| 260 | 274 |
| 261 # | 275 # |
| 262 # $Log: not supported by cvs2svn $ | 276 # $Log: not supported by cvs2svn $ |
| 277 # Revision 1.12 2001/12/17 03:52:48 richard | |
| 278 # Implemented file store rollback. As a bonus, the hyperdb is now capable of | |
| 279 # storing more than one file per node - if a property name is supplied, | |
| 280 # the file is called designator.property. | |
| 281 # I decided not to migrate the existing files stored over to the new naming | |
| 282 # scheme - the FileClass just doesn't specify the property name. | |
| 283 # | |
| 263 # Revision 1.11 2001/12/10 23:17:20 richard | 284 # Revision 1.11 2001/12/10 23:17:20 richard |
| 264 # Added transaction tests to test_db | 285 # Added transaction tests to test_db |
| 265 # | 286 # |
| 266 # Revision 1.10 2001/12/03 21:33:39 richard | 287 # Revision 1.10 2001/12/03 21:33:39 richard |
| 267 # Fixes so the tests use commit and not close | 288 # Fixes so the tests use commit and not close |
