Mercurial > p > roundup > code
comparison test/db_test_base.py @ 4005:3dec28d96583 1.4.5
fix some unit tests for python2.3
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 19 Aug 2008 01:40:59 +0000 |
| parents | 953234004ba2 |
| children | 5eb5f7e66c37 |
comparison
equal
deleted
inserted
replaced
| 4004:e437f4031310 | 4005:3dec28d96583 |
|---|---|
| 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.100 2008-08-19 00:52:01 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, sets, base64, os.path |
| 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 |
| 278 u1 = self.db.user.create(username='foo%s'%commit) | 278 u1 = self.db.user.create(username='foo%s'%commit) |
| 279 u2 = self.db.user.create(username='bar%s'%commit) | 279 u2 = self.db.user.create(username='bar%s'%commit) |
| 280 # try a couple of the built-in iterable types to make | 280 # try a couple of the built-in iterable types to make |
| 281 # sure that we accept them and handle them properly | 281 # sure that we accept them and handle them properly |
| 282 # try a set as input for the multilink | 282 # try a set as input for the multilink |
| 283 nid = self.db.issue.create(title="spam", nosy=set(u1)) | 283 nid = self.db.issue.create(title="spam", nosy=sets.Set(u1)) |
| 284 if commit: self.db.commit() | 284 if commit: self.db.commit() |
| 285 self.assertEqual(self.db.issue.get(nid, "nosy"), [u1]) | 285 self.assertEqual(self.db.issue.get(nid, "nosy"), [u1]) |
| 286 self.assertRaises(TypeError, self.db.issue.set, nid, | 286 self.assertRaises(TypeError, self.db.issue.set, nid, |
| 287 nosy='invalid type') | 287 nosy='invalid type') |
| 288 # test with a tuple | 288 # test with a tuple |
| 289 self.db.issue.set(nid, nosy=tuple()) | 289 self.db.issue.set(nid, nosy=tuple()) |
| 290 if commit: self.db.commit() | 290 if commit: self.db.commit() |
| 291 self.assertEqual(self.db.issue.get(nid, "nosy"), []) | 291 self.assertEqual(self.db.issue.get(nid, "nosy"), []) |
| 292 # make sure we accept a frozen set | 292 # make sure we accept a frozen set |
| 293 self.db.issue.set(nid, nosy=frozenset([u1,u2])) | 293 self.db.issue.set(nid, nosy=sets.Set([u1,u2])) |
| 294 if commit: self.db.commit() | 294 if commit: self.db.commit() |
| 295 l = [u1,u2]; l.sort() | 295 l = [u1,u2]; l.sort() |
| 296 m = self.db.issue.get(nid, "nosy"); m.sort() | 296 m = self.db.issue.get(nid, "nosy"); m.sort() |
| 297 self.assertEqual(l, m) | 297 self.assertEqual(l, m) |
| 298 | 298 |
| 1792 self.failUnless("From: admin" in mail_msg) | 1792 self.failUnless("From: admin" in mail_msg) |
| 1793 self.failUnless("Subject: [issue1] spam" in mail_msg) | 1793 self.failUnless("Subject: [issue1] spam" in mail_msg) |
| 1794 self.failUnless("New submission from admin" in mail_msg) | 1794 self.failUnless("New submission from admin" in mail_msg) |
| 1795 self.failUnless("one two" in mail_msg) | 1795 self.failUnless("one two" in mail_msg) |
| 1796 self.failIf("File 'test1.txt' not attached" in mail_msg) | 1796 self.failIf("File 'test1.txt' not attached" in mail_msg) |
| 1797 self.failUnless(base64.b64encode("xxx") in mail_msg) | 1797 self.failUnless(base64.encodestring("xxx").rstrip() in mail_msg) |
| 1798 self.failUnless("File 'test2.txt' not attached" in mail_msg) | 1798 self.failUnless("File 'test2.txt' not attached" in mail_msg) |
| 1799 self.failIf(base64.b64encode("yyy") in mail_msg) | 1799 self.failIf(base64.encodestring("yyy").rstrip() in mail_msg) |
| 1800 finally : | 1800 finally : |
| 1801 Mailer.smtp_send = backup | 1801 Mailer.smtp_send = backup |
| 1802 | 1802 |
| 1803 class ROTest(MyTestCase): | 1803 class ROTest(MyTestCase): |
| 1804 def setUp(self): | 1804 def setUp(self): |
