Mercurial > p > roundup > code
comparison test/test_db.py @ 646:07abfe8f0c01
use blobfiles in back_anydbm which is used in back_bsddb.
change test_db as dirlist does not work for subdirectories.
ATTENTION: blobfiles now creates subdirectories for files.
| author | Engelbert Gruber <grubert@users.sourceforge.net> |
|---|---|
| date | Mon, 25 Feb 2002 14:34:31 +0000 |
| parents | e346a9792335 |
| children | bc46480e2a2b 54333751e98d |
comparison
equal
deleted
inserted
replaced
| 645:e6d1c6d66de3 | 646:07abfe8f0c01 |
|---|---|
| 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.18 2002-01-22 07:21:13 richard Exp $ | 18 # $Id: test_db.py,v 1.19 2002-02-25 14:34:31 grubert 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 |
| 97 self.db.issue.history('5') | 97 self.db.issue.history('5') |
| 98 self.db.status.history('1') | 98 self.db.status.history('1') |
| 99 self.db.status.history('2') | 99 self.db.status.history('2') |
| 100 | 100 |
| 101 def testTransactions(self): | 101 def testTransactions(self): |
| 102 # remember the number of items we started | |
| 102 num_issues = len(self.db.issue.list()) | 103 num_issues = len(self.db.issue.list()) |
| 103 files_dir = os.path.join('_test_dir', 'files') | 104 num_files = self.db.numfiles() |
| 104 if os.path.exists(files_dir): | |
| 105 num_files = len(os.listdir(files_dir)) | |
| 106 else: | |
| 107 num_files = 0 | |
| 108 self.db.issue.create(title="don't commit me!", status='1') | 105 self.db.issue.create(title="don't commit me!", status='1') |
| 109 self.assertNotEqual(num_issues, len(self.db.issue.list())) | 106 self.assertNotEqual(num_issues, len(self.db.issue.list())) |
| 110 self.db.rollback() | 107 self.db.rollback() |
| 111 self.assertEqual(num_issues, len(self.db.issue.list())) | 108 self.assertEqual(num_issues, len(self.db.issue.list())) |
| 112 self.db.issue.create(title="please commit me!", status='1') | 109 self.db.issue.create(title="please commit me!", status='1') |
| 115 self.assertNotEqual(num_issues, len(self.db.issue.list())) | 112 self.assertNotEqual(num_issues, len(self.db.issue.list())) |
| 116 self.db.rollback() | 113 self.db.rollback() |
| 117 self.assertNotEqual(num_issues, len(self.db.issue.list())) | 114 self.assertNotEqual(num_issues, len(self.db.issue.list())) |
| 118 self.db.file.create(name="test", type="text/plain", content="hi") | 115 self.db.file.create(name="test", type="text/plain", content="hi") |
| 119 self.db.rollback() | 116 self.db.rollback() |
| 120 self.assertEqual(num_files, len(os.listdir(files_dir))) | 117 self.assertEqual(num_files, self.db.numfiles()) |
| 121 self.db.file.create(name="test", type="text/plain", content="hi") | 118 for i in range(10): |
| 122 self.db.commit() | 119 self.db.file.create(name="test", type="text/plain", |
| 123 self.assertNotEqual(num_files, len(os.listdir(files_dir))) | 120 content="hi %d"%(i)) |
| 124 num_files2 = len(os.listdir(files_dir)) | 121 self.db.commit() |
| 122 num_files2 = self.db.numfiles() | |
| 123 self.assertNotEqual(num_files, num_files2) | |
| 125 self.db.file.create(name="test", type="text/plain", content="hi") | 124 self.db.file.create(name="test", type="text/plain", content="hi") |
| 126 self.db.rollback() | 125 self.db.rollback() |
| 127 self.assertNotEqual(num_files, len(os.listdir(files_dir))) | 126 self.assertNotEqual(num_files, self.db.numfiles()) |
| 128 self.assertEqual(num_files2, len(os.listdir(files_dir))) | 127 self.assertEqual(num_files2, self.db.numfiles()) |
| 128 | |
| 129 | 129 |
| 130 | 130 |
| 131 def testExceptions(self): | 131 def testExceptions(self): |
| 132 # this tests the exceptions that should be raised | 132 # this tests the exceptions that should be raised |
| 133 ar = self.assertRaises | 133 ar = self.assertRaises |
| 344 | 344 |
| 345 return unittest.TestSuite(l) | 345 return unittest.TestSuite(l) |
| 346 | 346 |
| 347 # | 347 # |
| 348 # $Log: not supported by cvs2svn $ | 348 # $Log: not supported by cvs2svn $ |
| 349 # Revision 1.18 2002/01/22 07:21:13 richard | |
| 350 # . fixed back_bsddb so it passed the journal tests | |
| 351 # | |
| 352 # ... it didn't seem happy using the back_anydbm _open method, which is odd. | |
| 353 # Yet another occurrance of whichdb not being able to recognise older bsddb | |
| 354 # databases. Yadda yadda. Made the HYPERDBDEBUG stuff more sane in the | |
| 355 # process. | |
| 356 # | |
| 349 # Revision 1.17 2002/01/22 05:06:09 rochecompaan | 357 # Revision 1.17 2002/01/22 05:06:09 rochecompaan |
| 350 # We need to keep the last 'set' entry in the journal to preserve | 358 # We need to keep the last 'set' entry in the journal to preserve |
| 351 # information on 'activity' for nodes. | 359 # information on 'activity' for nodes. |
| 352 # | 360 # |
| 353 # Revision 1.16 2002/01/21 16:33:20 rochecompaan | 361 # Revision 1.16 2002/01/21 16:33:20 rochecompaan |
