Mercurial > p > roundup > code
comparison test/db_test_base.py @ 2098:18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
...(well, sqlite too, but that doesn't care).
Probably should use BOOLEAN instead of INTEGER for the Boolean props.
Need to fix a bizzaro MySQL error (gee, how unusual)
Need to finish MySQL migration from "version 1" database schemas.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 22 Mar 2004 07:45:40 +0000 |
| parents | 93f03c6714d8 |
| children | 666402433998 |
comparison
equal
deleted
inserted
replaced
| 2097:37ede7c5f5c5 | 2098:18addf2a8596 |
|---|---|
| 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: db_test_base.py,v 1.18 2004-03-19 04:47:59 richard Exp $ | 18 # $Id: db_test_base.py,v 1.19 2004-03-22 07:45:40 richard Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil, errno, imp, sys, time, pprint | 20 import unittest, os, shutil, errno, imp, sys, time, pprint |
| 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, Node | 23 Interval, DatabaseError, Boolean, Number, Node |
| 108 setupSchema(self.db, 0, self.module) | 108 setupSchema(self.db, 0, self.module) |
| 109 i = self.db.issue | 109 i = self.db.issue |
| 110 i.set(id1, title='asfasd') | 110 i.set(id1, title='asfasd') |
| 111 self.assertNotEqual(i.get(id1, 'creator'), i.get(id1, 'actor')) | 111 self.assertNotEqual(i.get(id1, 'creator'), i.get(id1, 'actor')) |
| 112 | 112 |
| 113 # | 113 # ID number controls |
| 114 # basic operations | |
| 115 # | |
| 116 def testIDGeneration(self): | 114 def testIDGeneration(self): |
| 117 id1 = self.db.issue.create(title="spam", status='1') | 115 id1 = self.db.issue.create(title="spam", status='1') |
| 118 id2 = self.db.issue.create(title="eggs", status='2') | 116 id2 = self.db.issue.create(title="eggs", status='2') |
| 119 self.assertNotEqual(id1, id2) | 117 self.assertNotEqual(id1, id2) |
| 120 | 118 def testIDSetting(self): |
| 119 # XXX numeric ids | |
| 120 self.db.setid('issue', 10) | |
| 121 id2 = self.db.issue.create(title="eggs", status='2') | |
| 122 self.assertEqual('11', id2) | |
| 123 | |
| 124 # | |
| 125 # basic operations | |
| 126 # | |
| 121 def testEmptySet(self): | 127 def testEmptySet(self): |
| 122 id1 = self.db.issue.create(title="spam", status='1') | 128 id1 = self.db.issue.create(title="spam", status='1') |
| 123 self.db.issue.set(id1) | 129 self.db.issue.set(id1) |
| 124 | 130 |
| 125 # String | 131 # String |
| 585 self.assertEqual('unlink', action) | 591 self.assertEqual('unlink', action) |
| 586 self.assertEqual(('issue', '1', 'assignedto'), params) | 592 self.assertEqual(('issue', '1', 'assignedto'), params) |
| 587 | 593 |
| 588 # test disabling journalling | 594 # test disabling journalling |
| 589 # ... get the last entry | 595 # ... get the last entry |
| 590 time.sleep(1) | 596 jlen = len(self.db.getjournal('user', '1')) |
| 591 entry = self.db.getjournal('issue', '1')[-1] | |
| 592 (x, date_stamp, x, x, x) = entry | |
| 593 self.db.issue.disableJournalling() | 597 self.db.issue.disableJournalling() |
| 594 self.db.issue.set('1', title='hello world') | 598 self.db.issue.set('1', title='hello world') |
| 595 self.db.commit() | 599 self.db.commit() |
| 596 entry = self.db.getjournal('issue', '1')[-1] | |
| 597 (x, date_stamp2, x, x, x) = entry | |
| 598 # see if the change was journalled when it shouldn't have been | 600 # see if the change was journalled when it shouldn't have been |
| 599 self.assertEqual(date_stamp, date_stamp2) | 601 self.assertEqual(jlen, len(self.db.getjournal('user', '1'))) |
| 600 time.sleep(1) | 602 jlen = len(self.db.getjournal('issue', '1')) |
| 601 self.db.issue.enableJournalling() | 603 self.db.issue.enableJournalling() |
| 602 self.db.issue.set('1', title='hello world 2') | 604 self.db.issue.set('1', title='hello world 2') |
| 603 self.db.commit() | 605 self.db.commit() |
| 604 entry = self.db.getjournal('issue', '1')[-1] | |
| 605 (x, date_stamp2, x, x, x) = entry | |
| 606 # see if the change was journalled | 606 # see if the change was journalled |
| 607 self.assertNotEqual(date_stamp, date_stamp2) | 607 self.assertNotEqual(jlen, len(self.db.getjournal('issue', '1'))) |
| 608 | 608 |
| 609 def testJournalPreCommit(self): | 609 def testJournalPreCommit(self): |
| 610 id = self.db.user.create(username="mary") | 610 id = self.db.user.create(username="mary") |
| 611 self.assertEqual(len(self.db.getjournal('user', id)), 1) | 611 self.assertEqual(len(self.db.getjournal('user', id)), 1) |
| 612 self.db.commit() | 612 self.db.commit() |
