Mercurial > p > roundup > code
diff test/db_test_base.py @ 3869:16faac822fe5
Allow Multilinks to take any iterable
Change create_inner & set_inner to allow any iterable for
Multilinks.
Added a test to make sure they work and that we raise an exception
for non-iterables.
| author | Justus Pendleton <jpend@users.sourceforge.net> |
|---|---|
| date | Wed, 29 Aug 2007 16:40:20 +0000 |
| parents | cf8b716d9ac2 |
| children | f0eb93f25d1c |
line wrap: on
line diff
--- a/test/db_test_base.py Tue Aug 28 22:37:45 2007 +0000 +++ b/test/db_test_base.py Wed Aug 29 16:40:20 2007 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: db_test_base.py,v 1.85 2007-04-11 20:04:06 forsberg Exp $ +# $Id: db_test_base.py,v 1.86 2007-08-29 16:40:20 jpend Exp $ import unittest, os, shutil, errno, imp, sys, time, pprint, sets @@ -253,6 +253,31 @@ m = self.db.issue.get(nid, "nosy"); m.sort() self.assertEqual(l, m) + def testMultilinkChangeIterable(self): + for commit in (0,1): + # invalid nosy value assertion + self.assertRaises(IndexError, self.db.issue.create, title='spam', + nosy=['foo%s'%commit]) + # invalid type for nosy create + self.assertRaises(TypeError, self.db.issue.create, title='spam', + nosy=1) + u1 = self.db.user.create(username='foo%s'%commit) + u2 = self.db.user.create(username='bar%s'%commit) + nid = self.db.issue.create(title="spam", nosy=set(u1)) # set + if commit: self.db.commit() + self.assertEqual(self.db.issue.get(nid, "nosy"), [u1]) + self.assertRaises(TypeError, self.db.issue.set, nid, + nosy='invalid type') + self.db.issue.set(nid, nosy=tuple()) # tuple + if commit: self.db.commit() + self.assertEqual(self.db.issue.get(nid, "nosy"), []) + self.db.issue.set(nid, nosy=frozenset([u1,u2])) # frozenset + if commit: self.db.commit() + l = [u1,u2]; l.sort() + m = self.db.issue.get(nid, "nosy"); m.sort() + self.assertEqual(l, m) + + # XXX one day, maybe... # def testMultilinkOrdering(self): # for i in range(10):
