Skip to content

Commit 2e1f199

Browse files
author
Ralf Schlatterbeck
committed
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...
1 parent f3ef277 commit 2e1f199

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

test/test_cgi.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
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 $
1212

1313
import unittest, os, shutil, errno, sys, difflib, cgi, re
1414

1515
from roundup.cgi import client
1616
from roundup.cgi.exceptions import FormError
17+
from roundup.cgi.templating import HTMLItem
1718
from roundup.cgi.form_parser import FormParser
1819
from roundup import init, instance, password, hyperdb, date
1920

@@ -191,6 +192,42 @@ def testEmptyStringSet(self):
191192
self.assertEqual(self.parseForm({'title': ' '}, 'issue', nodeid),
192193
({('issue', nodeid): {'title': None}}, []))
193194

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+
194231
def testFileUpload(self):
195232
file = FileUpload('foo', 'foo.txt')
196233
self.assertEqual(self.parseForm({'content': file}, 'file'),

0 commit comments

Comments
 (0)