Mercurial > p > roundup > code
comparison test/test_cgi.py @ 3859:9e48fda4a41c
Added two new tests for Links and Multilinks in HTMLItems:
An Item, when dereferencing a Link or Multilink should return the
correct items from the database.
Now if we name the linked items with numeric names (in the Link
example we have a status with id='1' and name='2' and vice-versa, in
the Multilink example we have the same for keyword) and the property
'name' of these items is also the key, it still works for Links but
not for Multilinks: The multilink in this case returns the keyword
with the *name* '1', not the one with the *id* '1'. I consider this a
bug and have implemented the test before looking deeper into it...
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Thu, 05 Jul 2007 19:21:57 +0000 |
| parents | 74aebbbea305 |
| children | 21420ba64b0d |
comparison
equal
deleted
inserted
replaced
| 3858:bb30bbfc7cdd | 3859:9e48fda4a41c |
|---|---|
| 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.29 2006-12-11 23:36:15 richard Exp $ | 11 # $Id: test_cgi.py,v 1.30 2007-07-05 19:21:57 schlatterbeck 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 | 15 from roundup.cgi import client |
| 16 from roundup.cgi.exceptions import FormError | 16 from roundup.cgi.exceptions import FormError |
| 17 from roundup.cgi.templating import HTMLItem | |
| 17 from roundup.cgi.form_parser import FormParser | 18 from roundup.cgi.form_parser import FormParser |
| 18 from roundup import init, instance, password, hyperdb, date | 19 from roundup import init, instance, password, hyperdb, date |
| 19 | 20 |
| 20 import db_test_base | 21 import db_test_base |
| 21 | 22 |
| 189 ({('issue', nodeid): {'title': None}}, [])) | 190 ({('issue', nodeid): {'title': None}}, [])) |
| 190 nodeid = self.db.issue.create(title='foo') | 191 nodeid = self.db.issue.create(title='foo') |
| 191 self.assertEqual(self.parseForm({'title': ' '}, 'issue', nodeid), | 192 self.assertEqual(self.parseForm({'title': ' '}, 'issue', nodeid), |
| 192 ({('issue', nodeid): {'title': None}}, [])) | 193 ({('issue', nodeid): {'title': None}}, [])) |
| 193 | 194 |
| 195 def testStringLinkId(self): | |
| 196 self.db.status.set('1', name='2') | |
| 197 self.db.status.set('2', name='1') | |
| 198 issue = self.db.issue.create(title='i1-status1', status='1') | |
| 199 self.assertEqual(self.db.issue.get(issue,'status'),'1') | |
| 200 self.assertEqual(self.db.status.lookup('1'),'2') | |
| 201 self.assertEqual(self.db.status.lookup('2'),'1') | |
| 202 form = cgi.FieldStorage() | |
| 203 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) | |
| 204 cl.classname = 'issue' | |
| 205 cl.nodeid = issue | |
| 206 cl.db = self.db | |
| 207 item = HTMLItem(cl, 'issue', issue) | |
| 208 self.assertEqual(item.status.id, '1') | |
| 209 self.assertEqual(item.status.name, '2') | |
| 210 | |
| 211 def testStringMultilinkId(self): | |
| 212 id = self.db.keyword.create(name='2') | |
| 213 self.assertEqual(id,'1') | |
| 214 id = self.db.keyword.create(name='1') | |
| 215 self.assertEqual(id,'2') | |
| 216 issue = self.db.issue.create(title='i1-status1', topic=['1']) | |
| 217 self.assertEqual(self.db.issue.get(issue,'topic'),['1']) | |
| 218 self.assertEqual(self.db.keyword.lookup('1'),'2') | |
| 219 self.assertEqual(self.db.keyword.lookup('2'),'1') | |
| 220 form = cgi.FieldStorage() | |
| 221 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) | |
| 222 cl.classname = 'issue' | |
| 223 cl.nodeid = issue | |
| 224 cl.db = self.db | |
| 225 cl.userid = '1' | |
| 226 item = HTMLItem(cl, 'issue', issue) | |
| 227 for topic in item.topic: | |
| 228 self.assertEqual(topic.id, '1') | |
| 229 self.assertEqual(topic.name, '2') | |
| 230 | |
| 194 def testFileUpload(self): | 231 def testFileUpload(self): |
| 195 file = FileUpload('foo', 'foo.txt') | 232 file = FileUpload('foo', 'foo.txt') |
| 196 self.assertEqual(self.parseForm({'content': file}, 'file'), | 233 self.assertEqual(self.parseForm({'content': file}, 'file'), |
| 197 ({('file', None): {'content': 'foo', 'name': 'foo.txt', | 234 ({('file', None): {'content': 'foo', 'name': 'foo.txt', |
| 198 'type': 'text/plain'}}, [])) | 235 'type': 'text/plain'}}, [])) |
