Mercurial > p > roundup > code
comparison test/test_schema.py @ 92:fa44da8d9df2
moving tests -> test
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 27 Jul 2001 06:55:07 +0000 |
| parents | |
| children | 0791d13baea7 |
comparison
equal
deleted
inserted
replaced
| 91:1c6520c82bfa | 92:fa44da8d9df2 |
|---|---|
| 1 # $Id: test_schema.py,v 1.1 2001-07-27 06:55:07 richard Exp $ | |
| 2 | |
| 3 import unittest, os, shutil | |
| 4 | |
| 5 from roundup.backends import anydbm | |
| 6 from roundup.hyperdb import String, Link, Multilink, Date, Interval, Class | |
| 7 | |
| 8 class SchemaTestCase(unittest.TestCase): | |
| 9 def setUp(self): | |
| 10 class Database(anydbm.Database): | |
| 11 pass | |
| 12 # remove previous test, ignore errors | |
| 13 if os.path.exists('_test_dir'): | |
| 14 shutil.rmtree('_test_dir') | |
| 15 os.mkdir('_test_dir') | |
| 16 self.db = Database('_test_dir', 'test') | |
| 17 self.db.clear() | |
| 18 | |
| 19 def tearDown(self): | |
| 20 self.db.close() | |
| 21 shutil.rmtree('_test_dir') | |
| 22 | |
| 23 def testA_Status(self): | |
| 24 status = Class(self.db, "status", name=String()) | |
| 25 self.assert_(status, 'no class object generated') | |
| 26 status.setkey("name") | |
| 27 val = status.create(name="unread") | |
| 28 self.assertEqual(val, '1', 'expecting "1"') | |
| 29 val = status.create(name="in-progress") | |
| 30 self.assertEqual(val, '2', 'expecting "2"') | |
| 31 val = status.create(name="testing") | |
| 32 self.assertEqual(val, '3', 'expecting "3"') | |
| 33 val = status.create(name="resolved") | |
| 34 self.assertEqual(val, '4', 'expecting "4"') | |
| 35 val = status.count() | |
| 36 self.assertEqual(val, 4, 'expecting 4') | |
| 37 val = status.list() | |
| 38 self.assertEqual(val, ['1', '2', '3', '4'], 'blah') | |
| 39 val = status.lookup("in-progress") | |
| 40 self.assertEqual(val, '2', 'expecting "2"') | |
| 41 status.retire('3') | |
| 42 val = status.list() | |
| 43 self.assertEqual(val, ['1', '2', '4'], 'blah') | |
| 44 | |
| 45 def testB_Issue(self): | |
| 46 issue = Class(self.db, "issue", title=String(), status=Link("status")) | |
| 47 self.assert_(issue, 'no class object returned') | |
| 48 | |
| 49 def testC_User(self): | |
| 50 user = Class(self.db, "user", username=String(), password=String()) | |
| 51 self.assert_(user, 'no class object returned') | |
| 52 user.setkey("username") | |
| 53 | |
| 54 | |
| 55 def suite(): | |
| 56 return unittest.makeSuite(SchemaTestCase, 'test') | |
| 57 | |
| 58 | |
| 59 # | |
| 60 # $Log: not supported by cvs2svn $ | |
| 61 # Revision 1.3 2001/07/25 04:34:31 richard | |
| 62 # Added id and log to tests files... | |
| 63 # | |
| 64 # |
