Mercurial > p > roundup > code
comparison test/test_db.py @ 927:51519406b73e
web forms may now unset Link values (like assignedto)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 31 Jul 2002 23:57:37 +0000 |
| parents | 502a5ae11cc5 |
| children | e21259073500 |
comparison
equal
deleted
inserted
replaced
| 926:3216c4f06ec4 | 927:51519406b73e |
|---|---|
| 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.38 2002-07-26 08:27:00 richard Exp $ | 18 # $Id: test_db.py,v 1.39 2002-07-31 23:57:37 richard Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil, time | 20 import unittest, os, shutil, time |
| 21 | 21 |
| 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ | 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ |
| 23 Interval, DatabaseError, Boolean, Number | 23 Interval, DatabaseError, Boolean, Number |
| 88 self.assertEqual(self.db.issue.get('2', 'title'), 'spam') | 88 self.assertEqual(self.db.issue.get('2', 'title'), 'spam') |
| 89 self.db.issue.set('2', title='ham') | 89 self.db.issue.set('2', title='ham') |
| 90 self.assertEqual(self.db.issue.get('2', 'title'), 'ham') | 90 self.assertEqual(self.db.issue.get('2', 'title'), 'ham') |
| 91 self.db.commit() | 91 self.db.commit() |
| 92 self.assertEqual(self.db.issue.get('2', 'title'), 'ham') | 92 self.assertEqual(self.db.issue.get('2', 'title'), 'ham') |
| 93 self.db.issue.set('1', title=None) | |
| 94 self.assertEqual(self.db.issue.get('1', "title"), None) | |
| 93 | 95 |
| 94 def testLinkChange(self): | 96 def testLinkChange(self): |
| 95 self.db.issue.create(title="spam", status='1') | 97 self.db.issue.create(title="spam", status='1') |
| 96 self.assertEqual(self.db.issue.get('1', "status"), '1') | 98 self.assertEqual(self.db.issue.get('1', "status"), '1') |
| 97 self.db.issue.set('1', status='2') | 99 self.db.issue.set('1', status='2') |
| 98 self.assertEqual(self.db.issue.get('1', "status"), '2') | 100 self.assertEqual(self.db.issue.get('1', "status"), '2') |
| 101 self.db.issue.set('1', status=None) | |
| 102 self.assertEqual(self.db.issue.get('1', "status"), None) | |
| 99 | 103 |
| 100 def testDateChange(self): | 104 def testDateChange(self): |
| 101 self.db.issue.create(title="spam", status='1') | 105 self.db.issue.create(title="spam", status='1') |
| 102 a = self.db.issue.get('1', "deadline") | 106 a = self.db.issue.get('1', "deadline") |
| 103 self.db.issue.set('1', deadline=date.Date()) | 107 self.db.issue.set('1', deadline=date.Date()) |
| 104 b = self.db.issue.get('1', "deadline") | 108 b = self.db.issue.get('1', "deadline") |
| 105 self.db.commit() | 109 self.db.commit() |
| 106 self.assertNotEqual(a, b) | 110 self.assertNotEqual(a, b) |
| 107 self.assertNotEqual(b, date.Date('1970-1-1 00:00:00')) | 111 self.assertNotEqual(b, date.Date('1970-1-1 00:00:00')) |
| 108 self.db.issue.set('1', deadline=date.Date()) | 112 self.db.issue.set('1', deadline=date.Date()) |
| 113 self.db.issue.set('1', deadline=None) | |
| 114 self.assertEqual(self.db.issue.get('1', "deadline"), None) | |
| 109 | 115 |
| 110 def testIntervalChange(self): | 116 def testIntervalChange(self): |
| 111 self.db.issue.create(title="spam", status='1') | 117 self.db.issue.create(title="spam", status='1') |
| 112 a = self.db.issue.get('1', "foo") | 118 a = self.db.issue.get('1', "foo") |
| 113 self.db.issue.set('1', foo=date.Interval('-1d')) | 119 self.db.issue.set('1', foo=date.Interval('-1d')) |
| 114 self.assertNotEqual(self.db.issue.get('1', "foo"), a) | 120 self.assertNotEqual(self.db.issue.get('1', "foo"), a) |
| 121 self.db.issue.set('1', foo=None) | |
| 122 self.assertEqual(self.db.issue.get('1', "foo"), None) | |
| 115 | 123 |
| 116 def testBooleanChange(self): | 124 def testBooleanChange(self): |
| 117 userid = self.db.user.create(username='foo', assignable=1) | 125 userid = self.db.user.create(username='foo', assignable=1) |
| 118 self.db.user.create(username='foo2', assignable=0) | 126 self.db.user.create(username='foo2', assignable=0) |
| 119 a = self.db.user.get(userid, 'assignable') | 127 a = self.db.user.get(userid, 'assignable') |
| 120 self.db.user.set(userid, assignable=0) | 128 self.db.user.set(userid, assignable=0) |
| 121 self.assertNotEqual(self.db.user.get(userid, 'assignable'), a) | 129 self.assertNotEqual(self.db.user.get(userid, 'assignable'), a) |
| 122 self.db.user.set(userid, assignable=0) | 130 self.db.user.set(userid, assignable=0) |
| 123 self.db.user.set(userid, assignable=1) | 131 self.db.user.set(userid, assignable=1) |
| 132 self.db.user.set('1', assignable=None) | |
| 133 self.assertEqual(self.db.user.get('1', "assignable"), None) | |
| 124 | 134 |
| 125 def testNumberChange(self): | 135 def testNumberChange(self): |
| 126 self.db.user.create(username='foo', age='1') | 136 self.db.user.create(username='foo', age='1') |
| 127 a = self.db.user.get('1', 'age') | 137 a = self.db.user.get('1', 'age') |
| 128 self.db.user.set('1', age='3') | 138 self.db.user.set('1', age='3') |
| 129 self.assertNotEqual(self.db.user.get('1', 'age'), a) | 139 self.assertNotEqual(self.db.user.get('1', 'age'), a) |
| 130 self.db.user.set('1', age='1.0') | 140 self.db.user.set('1', age='1.0') |
| 141 self.db.user.set('1', age=None) | |
| 142 self.assertEqual(self.db.user.get('1', "age"), None) | |
| 131 | 143 |
| 132 def testNewProperty(self): | 144 def testNewProperty(self): |
| 133 self.db.issue.create(title="spam", status='1') | 145 self.db.issue.create(title="spam", status='1') |
| 134 self.db.issue.addprop(fixer=Link("user")) | 146 self.db.issue.addprop(fixer=Link("user")) |
| 135 props = self.db.issue.getprops() | 147 props = self.db.issue.getprops() |
| 574 def suite(): | 586 def suite(): |
| 575 l = [ | 587 l = [ |
| 576 unittest.makeSuite(anydbmDBTestCase, 'test'), | 588 unittest.makeSuite(anydbmDBTestCase, 'test'), |
| 577 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') | 589 unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test') |
| 578 ] | 590 ] |
| 579 # return unittest.TestSuite(l) | 591 #return unittest.TestSuite(l) |
| 580 | 592 |
| 581 try: | 593 try: |
| 582 import bsddb | 594 import bsddb |
| 583 l.append(unittest.makeSuite(bsddbDBTestCase, 'test')) | 595 l.append(unittest.makeSuite(bsddbDBTestCase, 'test')) |
| 584 l.append(unittest.makeSuite(bsddbReadOnlyDBTestCase, 'test')) | 596 l.append(unittest.makeSuite(bsddbReadOnlyDBTestCase, 'test')) |
| 601 | 613 |
| 602 return unittest.TestSuite(l) | 614 return unittest.TestSuite(l) |
| 603 | 615 |
| 604 # | 616 # |
| 605 # $Log: not supported by cvs2svn $ | 617 # $Log: not supported by cvs2svn $ |
| 618 # Revision 1.38 2002/07/26 08:27:00 richard | |
| 619 # Very close now. The cgi and mailgw now use the new security API. The two | |
| 620 # templates have been migrated to that setup. Lots of unit tests. Still some | |
| 621 # issue in the web form for editing Roles assigned to users. | |
| 622 # | |
| 606 # Revision 1.37 2002/07/25 07:14:06 richard | 623 # Revision 1.37 2002/07/25 07:14:06 richard |
| 607 # Bugger it. Here's the current shape of the new security implementation. | 624 # Bugger it. Here's the current shape of the new security implementation. |
| 608 # Still to do: | 625 # Still to do: |
| 609 # . call the security funcs from cgi and mailgw | 626 # . call the security funcs from cgi and mailgw |
| 610 # . change shipped templates to include correct initialisation and remove | 627 # . change shipped templates to include correct initialisation and remove |
