Mercurial > p > roundup > code
comparison test/test_cgi.py @ 3969:905faf52a51f 1.4.3
fix mysql breakage in 1.4.2
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 27 Feb 2008 08:32:51 +0000 |
| parents | 1b84355e346a |
| children | 3167ad1c19cd |
comparison
equal
deleted
inserted
replaced
| 3968:5857cd1a0db9 | 3969:905faf52a51f |
|---|---|
| 6 # | 6 # |
| 7 # This module is distributed in the hope that it will be useful, | 7 # This module is distributed in the hope that it will be useful, |
| 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 10 # | 10 # |
| 11 # $Id: test_cgi.py,v 1.33 2007-10-05 03:07:14 richard Exp $ | 11 # $Id: test_cgi.py,v 1.34 2008-02-27 08:32:51 richard Exp $ |
| 12 | 12 |
| 13 import unittest, os, shutil, errno, sys, difflib, cgi, re | 13 import unittest, os, shutil, errno, sys, difflib, cgi, re |
| 14 | 14 |
| 15 from roundup.cgi import client, actions, exceptions | 15 from roundup.cgi import client, actions, exceptions |
| 16 from roundup.cgi.exceptions import FormError | 16 from roundup.cgi.exceptions import FormError |
| 87 def parseForm(self, form, classname='test', nodeid=None): | 87 def parseForm(self, form, classname='test', nodeid=None): |
| 88 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, | 88 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, |
| 89 makeForm(form)) | 89 makeForm(form)) |
| 90 cl.classname = classname | 90 cl.classname = classname |
| 91 cl.nodeid = nodeid | 91 cl.nodeid = nodeid |
| 92 cl.language = ('en',) | |
| 92 cl.db = self.db | 93 cl.db = self.db |
| 93 return cl.parsePropsFromForm(create=1) | 94 return cl.parsePropsFromForm(create=1) |
| 94 | 95 |
| 95 def tearDown(self): | 96 def tearDown(self): |
| 96 self.db.close() | 97 self.db.close() |
| 202 form = cgi.FieldStorage() | 203 form = cgi.FieldStorage() |
| 203 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) | 204 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) |
| 204 cl.classname = 'issue' | 205 cl.classname = 'issue' |
| 205 cl.nodeid = issue | 206 cl.nodeid = issue |
| 206 cl.db = self.db | 207 cl.db = self.db |
| 208 cl.language = ('en',) | |
| 207 item = HTMLItem(cl, 'issue', issue) | 209 item = HTMLItem(cl, 'issue', issue) |
| 208 self.assertEqual(item.status.id, '1') | 210 self.assertEqual(item.status.id, '1') |
| 209 self.assertEqual(item.status.name, '2') | 211 self.assertEqual(item.status.name, '2') |
| 210 | 212 |
| 211 def testStringMultilinkId(self): | 213 def testStringMultilinkId(self): |
| 220 form = cgi.FieldStorage() | 222 form = cgi.FieldStorage() |
| 221 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) | 223 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) |
| 222 cl.classname = 'issue' | 224 cl.classname = 'issue' |
| 223 cl.nodeid = issue | 225 cl.nodeid = issue |
| 224 cl.db = self.db | 226 cl.db = self.db |
| 227 cl.language = ('en',) | |
| 225 cl.userid = '1' | 228 cl.userid = '1' |
| 226 item = HTMLItem(cl, 'issue', issue) | 229 item = HTMLItem(cl, 'issue', issue) |
| 227 for keyword in item.keyword: | 230 for keyword in item.keyword: |
| 228 self.assertEqual(keyword.id, '1') | 231 self.assertEqual(keyword.id, '1') |
| 229 self.assertEqual(keyword.name, '2') | 232 self.assertEqual(keyword.name, '2') |
| 302 form.list.append(cgi.MiniFieldStorage('nosy', '3')) | 305 form.list.append(cgi.MiniFieldStorage('nosy', '3')) |
| 303 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) | 306 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) |
| 304 cl.classname = 'issue' | 307 cl.classname = 'issue' |
| 305 cl.nodeid = None | 308 cl.nodeid = None |
| 306 cl.db = self.db | 309 cl.db = self.db |
| 310 cl.language = ('en',) | |
| 307 self.assertEqual(cl.parsePropsFromForm(create=1), | 311 self.assertEqual(cl.parsePropsFromForm(create=1), |
| 308 ({('issue', None): {'nosy': ['1','2', '3']}}, [])) | 312 ({('issue', None): {'nosy': ['1','2', '3']}}, [])) |
| 309 | 313 |
| 310 def testEmptyMultilinkSet(self): | 314 def testEmptyMultilinkSet(self): |
| 311 nodeid = self.db.issue.create(nosy=['1','2']) | 315 nodeid = self.db.issue.create(nosy=['1','2']) |
| 604 makeForm(form)) | 608 makeForm(form)) |
| 605 cl.classname = 'user' | 609 cl.classname = 'user' |
| 606 cl.nodeid = '1' | 610 cl.nodeid = '1' |
| 607 cl.db = self.db | 611 cl.db = self.db |
| 608 cl.userid = '2' | 612 cl.userid = '2' |
| 613 cl.language = ('en',) | |
| 609 return cl | 614 return cl |
| 610 | 615 |
| 611 def testClassPermission(self): | 616 def testClassPermission(self): |
| 612 cl = self._make_client(dict(username='bob')) | 617 cl = self._make_client(dict(username='bob')) |
| 613 self.failUnlessRaises(exceptions.Unauthorised, | 618 self.failUnlessRaises(exceptions.Unauthorised, |
