Mercurial > p > roundup > code
comparison test/test_db.py @ 543:22e0edf7da6e
lots of date/interval related changes: more relaxed date format for input
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 16 Jan 2002 07:02:57 +0000 |
| parents | dce4c75bef5a |
| children | 5fd94347c6f2 |
comparison
equal
deleted
inserted
replaced
| 542:d17eecdcfe35 | 543:22e0edf7da6e |
|---|---|
| 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.13 2002-01-14 02:20:15 richard Exp $ | 18 # $Id: test_db.py,v 1.14 2002-01-16 07:02:57 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 |
| 24 from roundup.roundupdb import FileClass | 24 from roundup.roundupdb import FileClass |
| 25 from roundup import date | |
| 25 | 26 |
| 26 def setupSchema(db, create): | 27 def setupSchema(db, create): |
| 27 status = Class(db, "status", name=String()) | 28 status = Class(db, "status", name=String()) |
| 28 status.setkey("name") | 29 status.setkey("name") |
| 29 if create: | 30 if create: |
| 31 status.create(name="in-progress") | 32 status.create(name="in-progress") |
| 32 status.create(name="testing") | 33 status.create(name="testing") |
| 33 status.create(name="resolved") | 34 status.create(name="resolved") |
| 34 Class(db, "user", username=String(), password=Password()) | 35 Class(db, "user", username=String(), password=Password()) |
| 35 Class(db, "issue", title=String(), status=Link("status"), | 36 Class(db, "issue", title=String(), status=Link("status"), |
| 36 nosy=Multilink("user")) | 37 nosy=Multilink("user"), deadline=Date(), foo=Interval()) |
| 37 FileClass(db, "file", name=String(), type=String()) | 38 FileClass(db, "file", name=String(), type=String()) |
| 38 db.commit() | 39 db.commit() |
| 39 | 40 |
| 40 class MyTestCase(unittest.TestCase): | 41 class MyTestCase(unittest.TestCase): |
| 41 def tearDown(self): | 42 def tearDown(self): |
| 74 self.db.issue.create(title="abuse", status='1') | 75 self.db.issue.create(title="abuse", status='1') |
| 75 self.db.issue.addprop(fixer=Link("user")) | 76 self.db.issue.addprop(fixer=Link("user")) |
| 76 props = self.db.issue.getprops() | 77 props = self.db.issue.getprops() |
| 77 keys = props.keys() | 78 keys = props.keys() |
| 78 keys.sort() | 79 keys.sort() |
| 79 self.assertEqual(keys, ['fixer', 'id', 'nosy', 'status', 'title']) | 80 self.assertEqual(keys, ['deadline', 'fixer', 'foo', 'id', 'nosy', |
| 81 'status', 'title']) | |
| 80 self.db.issue.set('5', status='2') | 82 self.db.issue.set('5', status='2') |
| 81 self.db.issue.get('5', "status") | 83 self.db.issue.get('5', "status") |
| 84 | |
| 85 a = self.db.issue.get('5', "deadline") | |
| 86 self.db.issue.set('5', deadline=date.Date()) | |
| 87 self.assertNotEqual(a, self.db.issue.get('5', "deadline")) | |
| 88 | |
| 89 a = self.db.issue.get('5', "foo") | |
| 90 self.db.issue.set('5', foo=date.Interval('-1d')) | |
| 91 self.assertNotEqual(a, self.db.issue.get('5', "foo")) | |
| 92 | |
| 82 self.db.status.get('2', "name") | 93 self.db.status.get('2', "name") |
| 83 self.db.issue.get('5', "title") | 94 self.db.issue.get('5', "title") |
| 84 self.db.issue.find(status = self.db.status.lookup("in-progress")) | 95 self.db.issue.find(status = self.db.status.lookup("in-progress")) |
| 85 self.db.commit() | 96 self.db.commit() |
| 86 self.db.issue.history('5') | 97 self.db.issue.history('5') |
| 272 | 283 |
| 273 return unittest.TestSuite(l) | 284 return unittest.TestSuite(l) |
| 274 | 285 |
| 275 # | 286 # |
| 276 # $Log: not supported by cvs2svn $ | 287 # $Log: not supported by cvs2svn $ |
| 288 # Revision 1.13 2002/01/14 02:20:15 richard | |
| 289 # . changed all config accesses so they access either the instance or the | |
| 290 # config attriubute on the db. This means that all config is obtained from | |
| 291 # instance_config instead of the mish-mash of classes. This will make | |
| 292 # switching to a ConfigParser setup easier too, I hope. | |
| 293 # | |
| 294 # At a minimum, this makes migration a _little_ easier (a lot easier in the | |
| 295 # 0.5.0 switch, I hope!) | |
| 296 # | |
| 277 # Revision 1.12 2001/12/17 03:52:48 richard | 297 # Revision 1.12 2001/12/17 03:52:48 richard |
| 278 # Implemented file store rollback. As a bonus, the hyperdb is now capable of | 298 # 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, | 299 # storing more than one file per node - if a property name is supplied, |
| 280 # the file is called designator.property. | 300 # the file is called designator.property. |
| 281 # I decided not to migrate the existing files stored over to the new naming | 301 # I decided not to migrate the existing files stored over to the new naming |
