Mercurial > p > roundup > code
comparison test/test_schema.py @ 858:2dd862af72ee
all storage-specific code (ie. backend) is now implemented by the backends
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sun, 14 Jul 2002 02:05:54 +0000 |
| parents | dce4c75bef5a |
| children | 9b910e8d987d |
comparison
equal
deleted
inserted
replaced
| 857:6dd691e37aa8 | 858:2dd862af72ee |
|---|---|
| 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_schema.py,v 1.7 2002-01-14 02:20:15 richard Exp $ | 18 # $Id: test_schema.py,v 1.8 2002-07-14 02:05:54 richard Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil | 20 import unittest, os, shutil |
| 21 | 21 |
| 22 from roundup.backends import anydbm | 22 from roundup.backends import back_anydbm |
| 23 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ | 23 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ |
| 24 Interval, Class | 24 Interval |
| 25 | 25 |
| 26 class config: | 26 class config: |
| 27 DATABASE='_test_dir' | 27 DATABASE='_test_dir' |
| 28 MAILHOST = 'localhost' | 28 MAILHOST = 'localhost' |
| 29 MAIL_DOMAIN = 'fill.me.in.' | 29 MAIL_DOMAIN = 'fill.me.in.' |
| 37 MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no' | 37 MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no' |
| 38 EMAIL_SIGNATURE_POSITION = 'bottom' | 38 EMAIL_SIGNATURE_POSITION = 'bottom' |
| 39 | 39 |
| 40 class SchemaTestCase(unittest.TestCase): | 40 class SchemaTestCase(unittest.TestCase): |
| 41 def setUp(self): | 41 def setUp(self): |
| 42 class Database(anydbm.Database): | |
| 43 pass | |
| 44 # remove previous test, ignore errors | 42 # remove previous test, ignore errors |
| 45 if os.path.exists(config.DATABASE): | 43 if os.path.exists(config.DATABASE): |
| 46 shutil.rmtree(config.DATABASE) | 44 shutil.rmtree(config.DATABASE) |
| 47 os.makedirs(config.DATABASE + '/files') | 45 os.makedirs(config.DATABASE + '/files') |
| 48 self.db = Database(config, 'test') | 46 self.db = back_anydbm.Database(config, 'test') |
| 49 self.db.clear() | 47 self.db.clear() |
| 50 | 48 |
| 51 def tearDown(self): | 49 def tearDown(self): |
| 52 shutil.rmtree('_test_dir') | 50 shutil.rmtree('_test_dir') |
| 53 | 51 |
| 54 def testA_Status(self): | 52 def testA_Status(self): |
| 55 status = Class(self.db, "status", name=String()) | 53 status = back_anydbm.Class(self.db, "status", name=String()) |
| 56 self.assert_(status, 'no class object generated') | 54 self.assert_(status, 'no class object generated') |
| 57 status.setkey("name") | 55 status.setkey("name") |
| 58 val = status.create(name="unread") | 56 val = status.create(name="unread") |
| 59 self.assertEqual(val, '1', 'expecting "1"') | 57 self.assertEqual(val, '1', 'expecting "1"') |
| 60 val = status.create(name="in-progress") | 58 val = status.create(name="in-progress") |
| 72 status.retire('3') | 70 status.retire('3') |
| 73 val = status.list() | 71 val = status.list() |
| 74 self.assertEqual(val, ['1', '2', '4'], 'blah') | 72 self.assertEqual(val, ['1', '2', '4'], 'blah') |
| 75 | 73 |
| 76 def testB_Issue(self): | 74 def testB_Issue(self): |
| 77 issue = Class(self.db, "issue", title=String(), status=Link("status")) | 75 issue = back_anydbm.Class(self.db, "issue", title=String(), |
| 76 status=Link("status")) | |
| 78 self.assert_(issue, 'no class object returned') | 77 self.assert_(issue, 'no class object returned') |
| 79 | 78 |
| 80 def testC_User(self): | 79 def testC_User(self): |
| 81 user = Class(self.db, "user", username=String(), password=Password()) | 80 user = back_anydbm.Class(self.db, "user", username=String(), |
| 81 password=Password()) | |
| 82 self.assert_(user, 'no class object returned') | 82 self.assert_(user, 'no class object returned') |
| 83 user.setkey("username") | 83 user.setkey("username") |
| 84 | 84 |
| 85 | 85 |
| 86 def suite(): | 86 def suite(): |
| 87 return unittest.makeSuite(SchemaTestCase, 'test') | 87 return unittest.makeSuite(SchemaTestCase, 'test') |
| 88 | 88 |
| 89 | 89 |
| 90 # | 90 # |
| 91 # $Log: not supported by cvs2svn $ | 91 # $Log: not supported by cvs2svn $ |
| 92 # Revision 1.7 2002/01/14 02:20:15 richard | |
| 93 # . changed all config accesses so they access either the instance or the | |
| 94 # config attriubute on the db. This means that all config is obtained from | |
| 95 # instance_config instead of the mish-mash of classes. This will make | |
| 96 # switching to a ConfigParser setup easier too, I hope. | |
| 97 # | |
| 98 # At a minimum, this makes migration a _little_ easier (a lot easier in the | |
| 99 # 0.5.0 switch, I hope!) | |
| 100 # | |
| 92 # Revision 1.6 2001/12/03 21:33:39 richard | 101 # Revision 1.6 2001/12/03 21:33:39 richard |
| 93 # Fixes so the tests use commit and not close | 102 # Fixes so the tests use commit and not close |
| 94 # | 103 # |
| 95 # Revision 1.5 2001/10/09 07:25:59 richard | 104 # Revision 1.5 2001/10/09 07:25:59 richard |
| 96 # Added the Password property type. See "pydoc roundup.password" for | 105 # Added the Password property type. See "pydoc roundup.password" for |
