Mercurial > p > roundup > code
comparison test/db_test_base.py @ 4089:eddb82d0964c
Add compatibility package to allow us to deal with Python versions 2.3..2.6.
Outstanding issues noted in roundup/anypy/TODO.txt
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 12 Mar 2009 02:52:56 +0000 |
| parents | 5eb5f7e66c37 |
| children | dcca66d56815 |
comparison
equal
deleted
inserted
replaced
| 4088:34434785f308 | 4089:eddb82d0964c |
|---|---|
| 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.101 2008-08-19 01:40:59 richard Exp $ | 18 # $Id: db_test_base.py,v 1.101 2008-08-19 01:40:59 richard Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets, base64, os.path | 20 import unittest, os, shutil, errno, imp, sys, time, pprint, base64, os.path |
| 21 # Python 2.3 ... 2.6 compatibility: | |
| 22 from roundup.anypy.sets_ import set | |
| 21 | 23 |
| 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ | 24 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ |
| 23 Interval, DatabaseError, Boolean, Number, Node | 25 Interval, DatabaseError, Boolean, Number, Node |
| 24 from roundup.mailer import Mailer | 26 from roundup.mailer import Mailer |
| 25 from roundup import date, password, init, instance, configuration, support | 27 from roundup import date, password, init, instance, configuration, support |
| 282 u1 = self.db.user.create(username='foo%s'%commit) | 284 u1 = self.db.user.create(username='foo%s'%commit) |
| 283 u2 = self.db.user.create(username='bar%s'%commit) | 285 u2 = self.db.user.create(username='bar%s'%commit) |
| 284 # try a couple of the built-in iterable types to make | 286 # try a couple of the built-in iterable types to make |
| 285 # sure that we accept them and handle them properly | 287 # sure that we accept them and handle them properly |
| 286 # try a set as input for the multilink | 288 # try a set as input for the multilink |
| 287 nid = self.db.issue.create(title="spam", nosy=sets.Set(u1)) | 289 nid = self.db.issue.create(title="spam", nosy=set(u1)) |
| 288 if commit: self.db.commit() | 290 if commit: self.db.commit() |
| 289 self.assertEqual(self.db.issue.get(nid, "nosy"), [u1]) | 291 self.assertEqual(self.db.issue.get(nid, "nosy"), [u1]) |
| 290 self.assertRaises(TypeError, self.db.issue.set, nid, | 292 self.assertRaises(TypeError, self.db.issue.set, nid, |
| 291 nosy='invalid type') | 293 nosy='invalid type') |
| 292 # test with a tuple | 294 # test with a tuple |
| 293 self.db.issue.set(nid, nosy=tuple()) | 295 self.db.issue.set(nid, nosy=tuple()) |
| 294 if commit: self.db.commit() | 296 if commit: self.db.commit() |
| 295 self.assertEqual(self.db.issue.get(nid, "nosy"), []) | 297 self.assertEqual(self.db.issue.get(nid, "nosy"), []) |
| 296 # make sure we accept a frozen set | 298 # make sure we accept a frozen set |
| 297 self.db.issue.set(nid, nosy=sets.Set([u1,u2])) | 299 self.db.issue.set(nid, nosy=set([u1,u2])) |
| 298 if commit: self.db.commit() | 300 if commit: self.db.commit() |
| 299 l = [u1,u2]; l.sort() | 301 l = [u1,u2]; l.sort() |
| 300 m = self.db.issue.get(nid, "nosy"); m.sort() | 302 m = self.db.issue.get(nid, "nosy"); m.sort() |
| 301 self.assertEqual(l, m) | 303 self.assertEqual(l, m) |
| 302 | 304 |
| 485 nodeids = self.db.status.getnodeids() | 487 nodeids = self.db.status.getnodeids() |
| 486 self.db.status.retire('1') | 488 self.db.status.retire('1') |
| 487 others = nodeids[:] | 489 others = nodeids[:] |
| 488 others.remove('1') | 490 others.remove('1') |
| 489 | 491 |
| 490 self.assertEqual(sets.Set(self.db.status.getnodeids()), | 492 self.assertEqual(set(self.db.status.getnodeids()), |
| 491 sets.Set(nodeids)) | 493 set(nodeids)) |
| 492 self.assertEqual(sets.Set(self.db.status.getnodeids(retired=True)), | 494 self.assertEqual(set(self.db.status.getnodeids(retired=True)), |
| 493 sets.Set(['1'])) | 495 set(['1'])) |
| 494 self.assertEqual(sets.Set(self.db.status.getnodeids(retired=False)), | 496 self.assertEqual(set(self.db.status.getnodeids(retired=False)), |
| 495 sets.Set(others)) | 497 set(others)) |
| 496 | 498 |
| 497 self.assert_(self.db.status.is_retired('1')) | 499 self.assert_(self.db.status.is_retired('1')) |
| 498 | 500 |
| 499 # make sure the list is different | 501 # make sure the list is different |
| 500 self.assertNotEqual(a, self.db.status.list()) | 502 self.assertNotEqual(a, self.db.status.list()) |
| 2052 | 2054 |
| 2053 # confirm journal's ok | 2055 # confirm journal's ok |
| 2054 self.db.getjournal('a', aid) | 2056 self.db.getjournal('a', aid) |
| 2055 | 2057 |
| 2056 class RDBMSTest: | 2058 class RDBMSTest: |
| 2057 ''' tests specific to RDBMS backends ''' | 2059 """ tests specific to RDBMS backends """ |
| 2058 def test_indexTest(self): | 2060 def test_indexTest(self): |
| 2059 self.assertEqual(self.db.sql_index_exists('_issue', '_issue_id_idx'), 1) | 2061 self.assertEqual(self.db.sql_index_exists('_issue', '_issue_id_idx'), 1) |
| 2060 self.assertEqual(self.db.sql_index_exists('_issue', '_issue_x_idx'), 0) | 2062 self.assertEqual(self.db.sql_index_exists('_issue', '_issue_x_idx'), 0) |
| 2061 | 2063 |
| 2062 | 2064 |
